2017-04-03 54 views
1

視圖分隔符似乎被TextView元素重疊,並在某些情況下在較大分辨率的屏幕上隱藏。Android UI - 如何使視圖分隔符與TextViews重疊可見?

代碼:

<?xml version="1.0" encoding="utf-8"?> 
<!-- This is the fragment to be displayed for a section associated with a tab --> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/activity_fragment3" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#F2F3F4" 
    android:baselineAligned="false"> 

    <LinearLayout 
     android:id="@+id/acc" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:paddingBottom="5dp" 
     android:background="@color/black" 
     android:orientation="vertical"> 

     <ImageView 
      android:id="@+id/imageView" 
      android:layout_width="wrap_content" 
      android:layout_height="90dp" 
      android:layout_gravity="center" 
      android:paddingTop="5dp" 
      app:srcCompat="@drawable/account" /> 

     <TextView 
      android:id="@+id/accName" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center" 
      android:text="Paul Johnston" 
      android:textColor="@color/white" 
      android:textSize="24sp" /> 
    </LinearLayout> 

    <LinearLayout 
     android:id="@+id/options" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/acc" 
     android:orientation="vertical" 
     android:layout_marginTop="45dp" 
     android:background="@color/white"> 

     <View 
      android:layout_width="match_parent" 
      android:layout_height="0.1dp" 
      android:background="#9e9e9e" 
      android:layout_marginBottom="8dp"/> 
    <TextView 
      android:id="@+id/rentSpace" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:paddingLeft="8dp" 
      android:text="Rent Your Space" 
      android:textSize="16sp" 
      android:drawableEnd="@drawable/arrow_right" 
      android:layout_marginEnd="8dp" 
      android:drawableStart="@drawable/rentspace" 
      android:drawablePadding="8dp" /> 

     <View 
      android:layout_width="match_parent" 
      android:layout_height="0.1dp" 
      android:background="#9e9e9e" 
      android:layout_marginTop="8dp" 
      android:layout_marginBottom="8dp" 
      android:layout_marginStart="45dp"/> 

     <TextView 
      android:id="@+id/accBooking" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:paddingLeft="8dp" 
      android:text="My Bookings" 
      android:textSize="16sp" 
      android:drawableEnd="@drawable/arrow_right" 
      android:layout_marginEnd="8dp" 
      android:drawableStart="@drawable/bookings" 
      android:drawablePadding="8dp"/> 

     <View 
      android:layout_width="match_parent" 
      android:layout_height="0.1dp" 
      android:background="#9e9e9e" 
      android:layout_marginTop="8dp" 
      android:layout_marginBottom="8dp" 
      android:layout_marginStart="45dp"/> 

     <TextView 
      android:id="@+id/payDetails" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:paddingLeft="8dp" 
      android:text="Payment" 
      android:textSize="16sp" 
      android:drawableEnd="@drawable/arrow_right" 
      android:layout_marginEnd="8dp" 
      android:drawableStart="@drawable/payment" 
      android:drawablePadding="8dp"/> 

     <View 
      android:layout_width="match_parent" 
      android:layout_height="0.1dp" 
      android:background="#9e9e9e" 
      android:layout_marginTop="8dp" 
      android:layout_marginBottom="8dp" 
      android:layout_marginStart="45dp"/> 

     <TextView 
      android:id="@+id/accnt" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:paddingLeft="8dp" 
      android:text="Account" 
      android:textSize="16sp" 
      android:drawableEnd="@drawable/arrow_right" 
      android:layout_marginEnd="8dp" 
      android:drawableStart="@drawable/settings" 
      android:drawablePadding="8dp"/> 

     <View 
      android:layout_width="match_parent" 
      android:layout_height="0.1dp" 
      android:background="#9e9e9e" 
      android:layout_marginTop="8dp" 
      android:layout_marginBottom="8dp" 
      android:layout_marginStart="45dp"/> 

     <TextView 
      android:id="@+id/accAbout" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:paddingLeft="8dp" 
      android:text="About" 
      android:textSize="16sp" 
      android:drawableEnd="@drawable/arrow_right" 
      android:layout_marginEnd="8dp" 
      android:drawableStart="@drawable/help" 
      android:drawablePadding="8dp"/> 

     <View 
      android:layout_width="match_parent" 
      android:layout_height="0.1dp" 
      android:layout_marginTop="8dp" 
      android:background="#9e9e9e" /> 
    </LinearLayout> 

    <RelativeLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:padding="20dp"> 

     <TextView 
      android:id="@+id/appLegal" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      android:layout_alignParentStart="true" 
      android:text="Legal" 
      android:textSize="10sp" /> 

     <TextView 
      android:id="@+id/Version" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      android:layout_alignParentEnd="true" 
      android:text="v1.0" 
      android:textSize="10sp" /> 
    </RelativeLayout> 
</RelativeLayout> 

結果: dividers gradually fade and disappear

關於如何解決此問題有什麼建議?

+0

像素多少,你認爲' 「0.1dp」'是在不同的屏幕密度? – njzk2

回答

1

我認爲你的分隔線不會與textviews重疊。正如您使用Linearlayoutvertical的方向。

試試這個:增加你的分頻器的height

<View 
     android:layout_width="match_parent" 
     android:layout_height="1dp" //change here 
     android:layout_marginTop="8dp" 
     android:background="#9e9e9e" /> 

你的身高android:layout_height="0.1dp"不會在更高分辨率的設備可見,因爲這設備在每密度更像素。

或者,您可以根據不同的dpi級別使用dimens.xml中的不同dimen值。

,如:

dimens.xml (hdpi) 

dimens.xml (xhdpi)等。

+0

頂部3分隔物與底部3分隔物在視覺上有所不同,你知道爲什麼嗎? – k4s

+1

我認爲這與你的可繪製圖像有關......因爲''代碼對於所有分隔符都是一樣的。 – rafsanahmad007