0

ここに画像の説明を入力

この図では、下部の TextView の左端が上部の TextView の左端に揃えられています。これにより、このプログラムの実際の実行中に上部のテキスト ビューのサイズが変更されると、下部のテキスト ビューの位置が変更され、その間に上部のテキスト ビューの幅が複数回変更されます。下部のテキスト ビューを固定位置にとどめたいのですが、上部のテキスト ビューから独立した位置にする方法がわかりません。一番下のテキスト ビューの左端を、たとえば Gain テキスト ビューの右端に揃えるにはどうすればよいですか?

xml コードは次のとおりです。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <TextView
        android:id="@+id/textViewFreq"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="24dp"
        android:text="TextView"
        android:textSize="18.0sp" />

    <SeekBar
        android:id="@+id/seekBarFreq"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/seekBarGain"
        android:layout_below="@+id/textViewFreq" />

    <SeekBar
        android:id="@+id/seekBarGain"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/textViewGain"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="14dp" />

    <TextView
        android:id="@+id/labelFrequency"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/seekBarFreq"
        android:layout_alignTop="@+id/textViewFreq"
        android:textSize="18.0sp"
        android:text="@string/tvFreq" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/seekBarGain"
        android:layout_alignLeft="@+id/seekBarGain"
         android:textSize="18.0sp"
        android:text="@string/tvGain" />



    <TextView
        android:id="@+id/textViewGain"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/textViewFreq"
        android:layout_below="@+id/seekBarFreq"
        android:layout_marginTop="48dp"
        android:text="TextView"
        android:textSize="18.0sp" />

</RelativeLayout>
4

2 に答える 2

0

これを試して :

<TextView
    android:id="@+id/textViewGain"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignTop="@+id/seekBarGain"
    android:layout_centerHorizontal="true"
    android:layout_marginLeft="37dip"
    android:text="TextView"
    android:textSize="18.0sp" />
于 2013-09-12T10:22:30.923 に答える
0

これを試して:

TextView ごとに android_gravity="top" を配置します。android:layout_alignParentTop="true" を使用するだけでなく、これらの 2 つのオプションから 1 つが機能する場合があります。

于 2013-09-12T10:15:37.250 に答える