2011-12-08 19 views
1

我想在android中开发一个类似于撰写短信视图的视图。我不是很熟悉所有的android视图元素。如何开发Android短信视图?

很明显,这个视图使用了一些文本框。但我想知道正在使用哪些布局。例如。当用户在消息字段中输入一些文本时,灰色字段会展开。

我该如何做到这一点,您还可以对此观点发表什么看法?

enter image description here

+0

你应该ATLEAST :) –

回答

4
<?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

下面是什么,你可以在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> 
+0

试过你有没有收到短信消息视图的例子吗? – user836026