私はしばらくの間、これを行うための最良の方法を見つけようとしてきました。私が欲しいのはこのようなものです:
コードで:
<?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" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true" >
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="Button" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="Button" />
</LinearLayout>
<ProgressBar
android:id="@+id/progressBar1"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/progressBar1"
android:layout_centerHorizontal="true"
android:layout_marginTop="50dp"
android:text="Button" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="49dp"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/progressBar1"
android:layout_centerHorizontal="true"
android:layout_marginBottom="52dp"
android:text="TextView" />
私はこのレイアウトを持っています:
ここでの問題は、マージンが固定量のdpiであるということです。これになんらかの流動性を持たせたい。
私がこれを望む方法:
プログレスバーの上のスペースは、最初のテキストの上、1番目と2番目のテキストの間、および2番目のテキストとプログレスバーの間の3つの等しい部分に分かれています。
不確定なプログレスバー-垂直方向と水平方向の両方の中央に配置されます。
プログレスバーの下のスペースは、プログレスバーとボタンの間、およびボタンと下部の線形レイアウトの間の2つの等しい部分に分かれています。
これを比較的行う方法はありますか?レイアウトファイルでそれを行うことを好みますが、プログラミングとスペーシングをプログラムで行うこともできます。