2016-11-24 64 views
0

我想在按鈕上方顯示TextView,但在API 21上方的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