0

私は互いに並べて設定しているテキスト ビューのペアを持っています。また、それらを垂直にレイアウトする必要があります。To View Fuel Stations を見ると、その上に Click Here が描かれています。ここで何を見逃したのですか?これが私のスクリーンショットです。

ここに画像の説明を入力

そして、これが私のレイアウト用のコードです。

<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/txtViewGPS"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="" 
    android:textSize="20sp"
    android:textColorLink="#FFFF00"
    android:textStyle="bold"/>
<TextView  android:id="@+id/txtView_5"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="" 
    android:layout_below="@+id/txtViewGPS"
    android:textSize="20sp"
    android:textColorLink="#FFFF00"
    android:textStyle="bold"/>
<TextView android:id="@+id/textView1_1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"
    android:singleLine="true" 
    android:text="To view Evacuation Routes - "
    android:textSize="20sp"
    android:textStyle="bold" 
    android:layout_marginRight="5dp"/>

<TextView  android:id="@+id/txtView1"
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="" 
    android:layout_toRightOf="@id/textView1_1"
    android:textSize="20sp"
    android:textStyle="bold"
    android:layout_alignParentRight="true"/>
<TextView  android:id="@+id/txtView1_5"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="" 
    android:layout_below="@+id/txtView1"
    android:textSize="20sp"
    android:textColorLink="#FFFF00"
    android:textStyle="bold"/>  
 <TextView android:id="@+id/textView2_1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"
    android:singleLine="true" 
    android:layout_below="@+id/txtView1_5"
    android:text="To view shelters - "
    android:textSize="20sp"
    android:textStyle="bold" 
    android:layout_marginRight="5dp"/>
<TextView  android:id="@+id/txtView2"
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/txtView1"
    android:text="" 
    android:layout_toRightOf="@id/textView2_1"
    android:textSize="20sp"
    android:textStyle="bold"
    android:layout_alignParentRight="true"/>
<TextView  android:id="@+id/txtView2_5"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="" 
    android:layout_below="@+id/txtView2_1"
    android:textSize="20sp"
    android:textColorLink="#FFFF00"
    android:textStyle="bold"/>  
 <TextView android:id="@+id/textView3_1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"
    android:singleLine="true" 
    android:layout_below="@+id/txtView2_5"
    android:text="To view Fuel Stations  - "
    android:textSize="20sp"
    android:textStyle="bold" 
    android:layout_marginRight="5dp"/>
<TextView  android:id="@+id/txtView3"
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/txtView2"
    android:layout_toRightOf="@id/textView3_1"
    android:text="" 
    android:textSize="20sp"
    android:textStyle="bold"
    android:layout_alignParentRight="true"/>

</RelativeLayout>
4

5 に答える 5

0

1 つではなく 2 つの textView を使用しようとしているため、ソリューションは最初から適切ではありません。画面が両方を保持できない場合、またはユーザーが OS により大きなフォントを使用するように設定した場合にどうなるかを考えてください。

考えられる解決策は次のとおりです。

  1. とにかく2つのテキストビューとカスタムメイドのレイアウト(flowLayoutなど)を使用してください。単語の代わりに textViews の全体を使用するため、お勧めしません。

  2. 単一の textView とHtml.fromHtmlを使用し、リンクのクリックを処理します。

  3. webView を使用して HTML コンテンツを表示し、リンクのクリックを処理します。特にスクロール可能なコンテナ内にある場合、webViewにはスクロールに関する奇妙な問題があるため、お勧めしません。

ところで、strings.xml に文字列を配置する必要があります。ローカリゼーションに特に適しています。

于 2013-06-14T21:04:00.987 に答える
0

これがうまくいくかどうかはわかりませんが、試してみてください。私のコメントは読みにくいかもしれません。

を削除android:layout_toRightOf="@id/textView2_1"textView2て追加してみてください

android:layout_alignRight="@+id/textView1"  <!-- or whatever is the id of the one above this one
于 2013-06-14T21:09:22.553 に答える
0

txtView2 は、txtView3_1 の右側に表示するように設定する必要があるときに、txtView2_1 の右側に表示するように設定されています (ガソリンスタンドを表示するため)。

ただし、ID に適切な名前を付ける必要があります。このままでは混乱しすぎます。

于 2013-06-14T21:06:48.297 に答える