2016-11-24 1 views
0

Я хочу показать TextView над кнопкой, но в API 21, Button выше TextView.TextView не отображается над кнопкой больше, чем API 21

see image, click here

Я стараюсь android:elevation но сделать тень для TextView, это не хорошо.

Я стараюсь android:translationZ="100dip" но, не работает.

мои XML коды:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:gravity="center_horizontal" 
     android:layout_margin="10dp"> 

     <Button 
      android:id="@+id/custom_listview_food" 
      android:text="@string/main_matrial1" 
      android:layout_width="fill_parent" 
      android:layout_height="60dp" 
      android:padding="10dp" 
      android:gravity="center_horizontal" 
      android:textSize="16sp" 
      android:background="@color/listview_matrial" 
      android:layout_marginBottom="5dp" 

      /> 

     <TextView 
      android:id="@+id/custom_listview_material1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="material 1" 
      android:textColor="@color/white" 
      android:textSize="20sp" 
      android:layout_alignRight="@id/custom_listview_food" 
      android:layout_marginTop="50dp" 
      android:layout_marginRight="10dp" 
      /> 
</RelativeLayout> 

ответ

0

Попробуйте это, если вы не удовлетворены пинг дизайн макет, в котором, как вы хотите экран. Я предложу вам.

<TextView 
    android:id="@+id/custom_listview_material1" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:text="material 1" 
    android:textColor="#000" 
    android:textSize="20sp" 
    android:gravity="center" 
    android:layout_alignRight="@id/custom_listview_food" 
    android:layout_marginTop="10dp" 
    android:layout_centerHorizontal="true" 
    /> 
<Button 
    android:id="@+id/custom_listview_food" 
    android:text="main_matrial1" 
    android:layout_width="fill_parent" 
    android:layout_height="60dp" 
    android:padding="10dp" 
    android:gravity="center_horizontal" 
    android:textSize="16sp" 
    android:layout_below="@+id/custom_listview_material1" 
    android:background="@color/colorPrimary" 
    android:layout_marginBottom="5dp" 
    /> 
</RelativeLayout> 
+0

спасибо, но с этим кодом, просто они изменили их position.I хотят кнопка идет под TextView. см. изображение – Arash