3

ラベルを希望の場所に配置できません。写真を見せます。

ここに画像の説明を入力

次のコードがあります。

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center"
    android:layout_weight="1"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/textViewNombreVideo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/imageViewLogo"
        android:layout_alignParentBottom="true"
        android:layout_alignRight="@+id/imageViewLogo"
        android:lines="2"
        android:scrollHorizontally="false"
        android:singleLine="false"
        android:text="Medium Text"
        android:textAppearance="?android:attr/textAppearance"
        android:textColor="@android:color/white"
        android:textColorLink="@android:color/white"
        android:textStyle="bold" />

    <ImageView
        android:id="@+id/imageViewLogo"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_above="@+id/textViewNombreVideo"
        android:layout_centerHorizontal="true"
        android:layout_margin="4dp"
        android:adjustViewBounds="true" />

</RelativeLayout>

画像は画像ビューの高さに収まります。それで問題ありません。テキストビューを画像の同じ左に配置したいと思います。

それは可能ですか?

4

4 に答える 4

4

このコードを試してください。

<?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"
    android:layout_gravity="center"
    android:layout_weight="1"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/textViewNombreVideo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:layout_alignLeft="@+id/imageViewLogo"
        android:layout_alignParentBottom="true"
        android:layout_alignRight="@+id/imageViewLogo"
        android:lines="2"
        android:scrollHorizontally="false"
        android:text="Medium Text"
        android:textAppearance="?android:attr/textAppearance"
        android:textColor="@android:color/black"
        android:textColorLink="@android:color/white"
        android:textStyle="bold"
        android:layout_marginBottom="10dp" />

    <ImageView
        android:id="@+id/imageViewLogo"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_above="@+id/textViewNombreVideo"
        android:layout_centerHorizontal="true"
        android:layout_margin="4dp"
        android:src="@drawable/ic_launcher"
        android:adjustViewBounds="true"
     />

</RelativeLayout>

このコードからのUIデザインの下。あなたの条件に従って。

ここに画像の説明を入力

于 2013-05-18T13:09:32.207 に答える
0

これを試して

調整する必要はありません。さようならの属性を設定RelativeLayoutするだけで簡単に達成できます。TextViewandroid:drawableTopTextView

例: android:drawableTop="@drawble/yourimage"

       <TextView
        android:id="@+id/textView"
         android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:drawableTop="@drawble/yourimage"
        android:text="Hello"
       />
于 2013-05-18T12:41:33.923 に答える
0

Gravity オプションを TextView に追加する必要があると思います。

android:gravity="中心"

于 2013-05-18T12:36:04.507 に答える
0

ImageView と TextView の代わりに Button を使用します。

<Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button Text"
        android:drawableTop="@drawable/youriconname"

        />

これを試してみてください..

于 2013-05-18T13:12:53.080 に答える