質問

私はお互いに実行しているRelativeLayoutで同じ高さにある2つのTextviewsに問題があります。

私は、次のレイアウトを使用します。

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout 
       xmlns:android="http://schemas.android.com/apk/res/android"
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent">

<ImageView 
       android:id="@+id/logo" 
       android:layout_width="wrap_content"
       android:layout_height="wrap_content" 
       android:adjustViewBounds="true"
       android:scaleType="centerInside"
       android:src="@drawable/icon" />

<TextView 
       android:id="@+id/name"
       android:layout_width="fill_parent"
       android:layout_height="wrap_content" 
       android:text="NameNameNameNameNameNameName"
       android:layout_alignParentTop="true"
       android:layout_toRightOf="@id/logo"
       android:gravity="clip_horizontal" 
       android:lines="1" />

<TextView 
      android:id="@+id/information"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Distance"
      android:layout_alignParentRight="true"
      android:layout_alignParentTop="true" />

<TextView
      android:id="@+id/nrcoupons"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Number"
      android:layout_alignRight="@id/information"
      android:layout_alignBottom="@id/logo" />

<TextView
      android:id="@+id/subcategory"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content" 
      android:text="Subcategory"
      android:layout_alignLeft="@id/name"
      android:layout_alignBottom="@id/logo" />

</RelativeLayout>

これは私にこのビューを提供します:

altテキストhttp://janusz.de/~janusz/view.pngする

すべては、私は他の上に1と同じ画面スペースに表示されている2つのtextviews名および情報以外にそれを必要とするようです。

どのように私はこれを避けることができますか?

役に立ちましたか?

解決

あなたの@+id/nameTextViewについては、右側にあるものは何でもandroid:layout_toLeftOf="..."ためTextViewを追加します。スクリーンショットおよびXMLは、(スクリーンショットが上書きのTextViewに「距離」を持っているように見えますが、XMLにはない)のラインアップしていないようですので、私はこれがどのウィジェット完全に一定ではないんです。

あなたは、Android 1.5をターゲットにしている場合、あなたは彼らがandroid:layout_toLeftOfまたはandroid:layout_toRightOfから参照される前に、ウィジェットが定義されているようにXMLでウィジェットを注文する必要があります。あなたは、Android 1.6以降をターゲットにしている場合にのみ、あなたは彼らがどのような順序でも持つことができますが、任意の個別IDの最初の出現は、最初に出現したが、代わりに+属性のandroid:layout_toLeftOf属性であっても、android:idサインを持っている必要があります。

他のヒント

あなたはその右には何も置くことができないので、

あなたのnamenamenameのTextViewには、幅= fill_parentに設定されている;)

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top