-3

どういうわけか、eclipse と android SDK を使用して設計するのに非常に苦労しています。レイアウトの作成は非常に難しく、WPF/Visual Studio ほど簡単ではありません。

私は次のことを達成しようとしています:

Top: what I have
Bottom: what I want to achieve

http://imgur.com/AsaTuGq

現在のコード:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="10dip"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<TextView
    android:textIsSelectable="false"
    android:id="@+id/line1"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:textSize="18sp"
    android:layout_weight="1"
    android:textStyle="bold"
    />

<TextView
    android:textIsSelectable="false"
    android:id="@+id/line2"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:textSize="18sp"
    />

<TextView
    android:textIsSelectable="false"
    android:id="@+id/line3"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_gravity="center"
    android:textSize="18sp"
    />

</LinearLayout>

編集:

また、Horizo​​ntal LinearLayout 内で Vertical LinearLayout を使用しようとしましたが、多くのエラーが発生しました。

編集2:

マイナス評価はどうした?

編集3:

このリンクを試してみました : http://android-developers.blogspot.ca/2009/02/android-layout-tricks-1.html

4

2 に答える 2

0

私はこれのために提案RelativeLayoutします

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="10dip"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<TextView
    android:textIsSelectable="false"
    android:id="@+id/line1"
    android:layout_width="wrap_content"
    android:layout_height="0dp"
    android:textSize="18sp"
    android:layout_weight="1"
    android:textStyle="bold"
    android:layout_alignParentLeft="true"
    />

<TextView
    android:textIsSelectable="false"
    android:id="@+id/line2"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:textSize="18sp"
    android:layout_alignParentLeft="true"
    android:layout_below="@_id/line1"
    />

<TextView
    android:textIsSelectable="false"
    android:id="@+id/line3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="center_vertical"
    android:layout_alignParentRight="true"
    android:textSize="18sp"
    />
</RelativeLayout>

変更点:

最初の2行と2行目に使用するように変更LinearLayoutされました。日付を右に移動し、これが必要なものに機能することを願っています。RelativeLayoutandroid:layout_alignParentLeft="true"android:layout_below="@+id/line1"android:layout_alignParentRight="true"android:gravity="center_vertical"

于 2013-03-07T21:28:11.427 に答える
0

RelativeLayout を使用する必要があります。

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

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="false"
        android:layout_alignParentTop="true"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Medium Text"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Medium Text"
            android:textAppearance="?android:attr/textAppearanceMedium" />

    </LinearLayout>

    <TextView
        android:id="@+id/textView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:text="Medium Text"
        android:textAppearance="?android:attr/textAppearanceMedium" />

</RelativeLayout>
于 2013-03-07T21:25:14.293 に答える