私は画面を水平に2分割して正しく動作するレイアウトを持っています。しかし、境界線(私のカスタムドロウアブルフォルダからの背景画像)を置こうとすると、2番目のTextViewはページの半分で開始しません。最初のビューの横に表示されます。どうすれば修正できますか?TextViews用の枠線を使用して画面を半分(水平)に分割する(Android)
ここは私のXMLの一部です。
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/border_tasks"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Bekleyen \n Görevler \n 10"
android:layout_weight="1"/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Biten \n Görevler \n 90"
android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>
ここでは完全なxmlです。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/activitychart"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/border_name"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text ="Adı Soyadı"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Anadolu Sigorta - Eksper"
/>
</LinearLayout>
<com.github.mikephil.charting.charts.PieChart
android:id="@+id/chart"
android:background="@drawable/border_name"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:paddingLeft="@dimen/_5sdp"
android:scaleX="1.02"
android:scaleY="1.02"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/border_tasks"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Bekleyen \n Görevler \n 10"
android:layout_weight="1"/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Biten \n Görevler \n 90"
android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>
そしてここでボーダータスクである(値は単にランダムである、あなたはそれらを変更することができます。)私は2つの異なるtextviewsを使用 理由は、私がどの広い境界線を追加した後、各テキストビューのための追加的な境界線を追加するということですそれらの両方
border_tasks.xml
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners android:radius="20dp"/>
<size android:width="@dimen/_160sdp" android:height="@dimen/_60sdp" ></size>
<padding android:left="10dp" android:right="@dimen/_160sdp" android:top="10dp" android:bottom="10dp"/>
<stroke android:width="1dp" android:color="#CCCCCC"/>
</shape>
ここでは、@ DIMEN/_160sdpはように160 DPを参照し、カプセル化します。私は価値観を持って遊んだが、うまくいかなかった。
実際には、textviewsが占める領域を確認するには、背景色を変更します。私はあなたが50/50であると思うでしょう。そのような場合は、TextViewのテキストの配置を確認してください。 – Juan
これらは50ではありません50. – Cem
コード内のレイアウトを変更していますか? – Juan