Как разработать андроид SMS View? - PullRequest
1 голос
/ 08 декабря 2011

Я хочу разработать представление в Android, которое похоже на представление составления SMS.Я не очень знаком со всеми элементами просмотра Android.

Очевидно, что в этом представлении используются некоторые текстовые поля.Но я хочу знать, какие макеты используются.Например, когда пользователь вводит какой-то текст в поле сообщения, поле Серый расширяется.

Как мне добиться этого и что еще вы можете сказать об этом представлении?

enter image description here

Ответы [ 2 ]

4 голосов
/ 09 декабря 2011
<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:a="http://schemas.android.com/apk/res/android"
                a:layout_width="fill_parent"
                a:layout_height="fill_parent">
    <LinearLayout
            a:orientation="vertical"
            a:layout_height="wrap_content"
            a:layout_width="fill_parent">
        <EditText
                a:id="@+id/smsRecipients"
                a:layout_height="wrap_content"
                a:layout_width="fill_parent"
                a:hint="@string/sms_to_whom"/>
        <Button
                a:layout_height="wrap_content"
                a:layout_width="fill_parent"
                a:text="@string/sms_contacts"
                a:onClick="onPickContact"/>
    </LinearLayout>

    <LinearLayout a:layout_alignParentBottom="true"
                  a:orientation="horizontal"
                  a:layout_width="fill_parent"
                  a:layout_height="wrap_content"
                  a:paddingTop="5dip"
                  a:paddingBottom="5dip"
                  a:paddingLeft="5dip"
                  a:paddingRight="5dip"
                  a:background="#dcdcdc">
        <EditText
                a:id="@+id/smsBody"
                a:layout_width="0dip"
                a:layout_height="wrap_content"
                a:layout_weight="1.0"
                a:autoText="true"
                a:capitalize="sentences"
                a:nextFocusRight="@+id/send_button"
                a:hint="@string/sms_enter_message"
                a:maxLines="10"
                a:inputType="textShortMessage|textAutoCorrect|textCapSentences|textMultiLine"
                a:imeOptions="actionSend|flagNoEnterAction"/>
        <LinearLayout a:orientation="vertical" a:layout_width="wrap_content" a:layout_height="fill_parent">
            <Button
                    a:id="@+id/smsSendButton"
                    a:layout_marginLeft="5dip"
                    a:layout_width="wrap_content"
                    a:layout_height="0dip"
                    a:layout_weight="1.0"
                    a:nextFocusLeft="@+id/smsBody"
                    a:text="@string/sms_send_abbr"
                    a:enabled="false"/>
        </LinearLayout>
    </LinearLayout>

</RelativeLayout>
2 голосов
/ 09 декабря 2011

Ниже вы можете написать в XML-файле, чтобы получить макет, как вы хотите. Вы можете изменить цвет макета фона или установить фоновое изображение в соответствии с вашими потребностями. Я просто дал код цвета для серого.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout 
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="1.0"
        android:orientation="vertical">
         <EditText 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"/>
    </LinearLayout>   
    <LinearLayout 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="#A9A9A9"
        android:paddingTop="5dp">
        <EditText 
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1.0"
            android:hint="Zum Schreiben eintippen"
            android:layout_gravity="center_vertical"
            android:maxLines="1"/>
        <Button 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Senden"
            android:layout_gravity="center_vertical"/>
    </LinearLayout>
</LinearLayout>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...