0

UI を希望どおりに表示するために、かなりの時間を費やしています。これが私が持っているものです...これが私が得たものです...

TextView、XX:XX:XX、テキスト フォントを大きくして、EditText と Button の間の中央に配置したいと思います。また、ユーザーがテキスト入力に使用する QWERTY キーボードの代わりに電話キーボードを使用するのはなぜですか?

これが私のレイアウト XML です。

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

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <EditText
        android:id="@+id/new_bookmark_name"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_weight="0.5"
        android:ems="10"
        android:inputType="text" />

    <TextView
        android:id="@+id/new_bookmark_clock"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_weight="0.3"
        android:text="@string/xx_xx_xx" />

    <Button
        android:id="@+id/btn_add_new_bookmark"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_weight="0.2"
        android:text="@string/add"/>
 </LinearLayout>

 <ListView
    android:id="@+id/bookmark_list"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"/>

 </LinearLayout>
4

5 に答える 5

4

次のコードを使用して、目的を達成します:......

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

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <EditText
        android:id="@+id/new_bookmark_name"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_weight="1"
        android:ems="10"
        android:inputType="text" />

    <TextView
        android:id="@+id/new_bookmark_clock"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:textSize="18dp"
        android:layout_weight="1"
        android:text="@string/xx_xx_xx" />

    <Button
        android:id="@+id/btn_add_new_bookmark"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_weight="1"
        android:text="@string/add"/>
 </LinearLayout>

 <ListView
    android:id="@+id/bookmark_list"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"/>

 </LinearLayout>
于 2013-09-18T03:57:42.553 に答える
1

以下に従ってください。相対レイアウトを使用し、最小数の行を使用して、まさにあなたが求めていたサンプル UI を作成しました。ご覧になり、目的を解決できるかどうかを確認してください。同じスナップショットも添付しました。

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

            <RelativeLayout
                android:padding="4dp"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                >

                <EditText
                    android:id="@+id/ed_name"
                    android:layout_width="100dp"
                    android:layout_height="wrap_content"
                    android:inputType="number" />

                <TextView
                    android:id="@+id/tv_name"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerVertical="true"
                    android:layout_toRightOf="@+id/ed_name"
                    android:text="XX:XX:XX"
                    android:textSize="18dp" />

                <Button
                    android:id="@+id/btn_name"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentRight="true"
                    android:text=" add " />
            </RelativeLayout>
            </RelativeLayout>

キーパッドについて:実際のデバイスで確認してください。デバイスは独自のデフォルトのキーパッドを開きます。ここに画像の説明を入力

于 2013-09-18T05:27:30.693 に答える
1

android:layout_gravity="center"で置き換えます

Android:gravity="center" を TextView に追加します。

キーボードレイアウトに関しては、エミュレータで試しているようです。エミュレーターは、縦向きモードで 12 パッドのキーボードを表示します。デバイスで試すことができます。

于 2013-09-18T03:30:53.890 に答える
1

これを行うには、相対レイアウトを使用できます。でフォントサイズを変更できますandroid:textSize

<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <EditText
        android:id="@+id/new_bookmark_name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:ems="10"
        android:inputType="text" />

    <TextView
        android:id="@+id/new_bookmark_clock"
        android:layout_width="wrap_content"
        android:layout_toRightOf="@id/new_bookmark_name"
        android:layout_toLeftOf="@+id/btn_add_new_bookmark"
        android:layout_height="wrap_content"
        android:textSize="20sp"
        android:text="@string/xx_xx_xx" />

    <Button
        android:id="@id/btn_add_new_bookmark"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:text="@string/add"/>
 </RelativeLayout>
于 2013-09-18T03:24:13.200 に答える