2016-11-15 1 views
1

Pleae взглянуть на следующий XMLAndroid LinearLayout Выравнивание по правому

я хочу Выравнивание изображения вправо перед текстом

please look to this image

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:background="@drawable/list_selector" 
android:orientation="horizontal" 
android:padding="6dp" > 

<LinearLayout 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center_vertical" 
    android:background="@drawable/rounded_corner" 
    android:orientation="vertical" > 

    <ImageView 
     android:id="@+id/image_category" 
     android:layout_width="72dp" 
     android:layout_height="72dp" 
     android:contentDescription="@string/app_name" 
     android:padding="0dp" 
     android:src="@drawable/ic_launcher" /> 
</LinearLayout> 

<LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center_vertical" 
    android:layout_marginLeft="8dp" 
    android:orientation="vertical" > 

    <TextView 
     android:id="@+id/txt_allphotos_categty" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="2dp" 
     android:layout_marginRight="2dp" 
     android:text="" 
     android:textColor="@color/texthoverclr" 
     android:gravity="right" 
     android:textSize="20sp" /> 
</LinearLayout> 

я хочу выровнять фотографию справа, затем текст после него вправо

+0

использовать относительные макете вместо линейного макета будет легко. –

+0

Вы можете включить поддержку RTL в манифесте. –

+0

Вы имеете в виду этот андроид: поддерживаетRtl = "true" ?? cand Вы можете отредактировать код для меня? – user3418508

ответ

1

Ключ один LinearLayout с тяжестью множества макета для android:gravity="end"

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:layout_width="match_parent" 
android:layout_height="60dp" 
android:layout_marginEnd="16dp" 
android:layout_marginStart="16dp" 
android:background="@color/black" 
android:gravity="end" 
android:orientation="horizontal"> 

<ImageView 
    android:layout_width="60dp" 
    android:layout_height="60dp" 
    android:layout_gravity="center" 
    android:src="@drawable/trophy" /> 

<vouchrapp.vouchr.AutoResizeTextView 
    android:id="@+id/toastTextView" 
    android:layout_width="wrap_content" 
    android:layout_height="match_parent" 
    android:layout_gravity="center" 
    android:gravity="center_vertical" 
    android:text="Hello" 
    android:textColor="@color/white" 
    android:textSize="18sp" /> 

</LinearLayout> 
+0

спасибо, его рабочий :) – user3418508

 Смежные вопросы

  • Нет связанных вопросов^_^