2017-04-03 9 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

関連する問題