0

Android デバイスで次のレイアウトを作成する必要があります。

レイアウト

要件は次のとおりです。画面全体を占める最初のレイアウト (fill_parent)。2 番目 (画面の下部) は最初のものをオーバーレイし、次の形式を持ちます。

  • 3列;
  • 画面幅全体を占めます。
  • 矢印は左右に配置され、テキスト領域は画面幅に基づいてサイズ変更されます。

私は多くのことを試しましたが、Android の世界は初めてなので、まだ成功していません。

これが私がこれまでに持っているものです:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:minWidth="25px"
    android:minHeight="25px"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:weightSum="100"
    android:id="@+id/RootView">
    <ImageView
        android:src="@android:drawable/ic_menu_gallery"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:scaleType="fitXY"
        android:id="@+id/mapImageView" />
    <LinearLayout
        android:id="@+id/bottomArea"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_alignParentBottom="true">
        <LinearLayout
            android:id="@+id/adsArea"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:orientation="horizontal"
            android:layout_alignParentBottom="true">
            <ImageButton
                android:src="@drawable/leftArrow"
                android:id="@+id/btnPrev"
                android:layout_alignParentRight="true"
                android:layout_marginLeft="0dip"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
            <LinearLayout
                android:orientation="vertical"
                android:layout_width="wrap_content"
                android:layout_height="fill_parent"
                android:layout_gravity="center">
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Title" />
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="This is some summary text" />
            </LinearLayout>
            <ImageButton
                android:src="@drawable/rightArrow"
                android:layout_alignParentRight="true"
                android:layout_marginRight="0dip"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/btnNext" />
        </LinearLayout>
    </LinearLayout>
</RelativeLayout>

しかし、テキストは中央揃えではなく、画面幅に合わせてサイズ変更されていないようです:

ここに画像の説明を入力

誰かが手がかりを持っていますか?

ありがとう。

4

2 に答える 2

0

以下のコードを見つけてください。また、単純なレイアウト ソリューションに複数のビューグループを使用しないでください。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/RootView"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <ImageView
        android:id="@+id/mapImageView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:src="@android:drawable/ic_menu_gallery" />

    <RelativeLayout
        android:id="@+id/adsArea"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true" >

        <ImageButton
            android:id="@+id/btnPrev"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:src="@drawable/leftArrow" />

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:orientation="vertical" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Title" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="This is some summary text" />
        </LinearLayout>

        <ImageButton
            android:id="@+id/btnNext"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:src="@drawable/rightArrow" />
    </RelativeLayout>

</RelativeLayout>
于 2013-04-23T07:00:50.210 に答える
0

必要なレイアウトにこのコードを使用してください...

<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"
tools:context=".MainActivity" >

<LinearLayout
    android:id="@+id/linear1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_above="@+id/linear2" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/ic_launcher" />
</LinearLayout>

<RelativeLayout
    android:id="@+id/linear2"
    android:layout_width="match_parent"
    android:layout_height="70dp"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true" >

    <ImageButton
        android:id="@+id/leftButton1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:src="@drawable/ic_launcher" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_toLeftOf="@+id/rightButton1"
        android:layout_toRightOf="@+id/leftButton1"
        android:gravity="center"
        android:orientation="vertical" >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Title" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="This is some summary text" />

    </LinearLayout>

    <ImageButton
        android:id="@+id/rightButton1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:src="@drawable/ic_launcher" />
</RelativeLayout>

于 2013-04-23T07:30:07.480 に答える