2016-09-20 118 views
0

我想做一个线性布局,其中有2个项目,一个项目是一个箭头,需要适合在屏幕的右侧,另一个项目是一个编辑文本,需要适合其余的视图。我尝试了很多方法来做到这一点,但他们都没有效果。我最近的尝试是使用layout_weight,但是这给我带来的问题是箭头在更大的手机上有太多的区域。Android LinearLayout开始从右边的项目

<LinearLayout 
     android:id="@+id/sendLayout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:gravity="center_vertical" 
     android:weightSum="2" 
     android:paddingBottom="@dimen/scale_5dp" 
     android:layout_marginLeft="@dimen/scale_10dp" 
     android:layout_marginRight="@dimen/scale_10dp" 
     android:layout_weight="0.2"> 



     <LinearLayout 
      android:layout_width='0dp' 
      android:layout_height="wrap_content" 
      android:layout_weight="1.7" 
      > 


      <com.heyjude.heyjudeapp.customview.EditRobotoRegular 
       android:id="@+id/editChatMsg" 
       android:layout_height="wrap_content" 
       android:layout_width="match_parent" 
       android:background="@drawable/linear_back" 
       android:hint="Type your message..." 
       android:padding="@dimen/scale_5dp" 
       android:inputType="textMultiLine|textCapSentences|text" 
       android:textColor="#5f6060" 
       android:textColorHint="#5f6060" 
       android:textSize="@dimen/text_14" 
       android:imeOptions="actionSend" 
       /> 
     </LinearLayout> 


     <ImageButton 
      android:id="@+id/ivSend" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/ic_chat_icon" 
      android:background="@android:color/transparent" 
      android:layout_weight="0.3" /> 

    </LinearLayout> 

这里是什么样子,因为它是目前,你可以看到周围有箭头太多空间

enter image description here

+0

我们在EditRobotoRegular中重量为10 ......之后它会变成相同的,然后你必须发布你的整个xml。由于其他的'VIEW',它可能会带来问题... – sushildlh

回答

1

试试这个...和更改图标和根据您的要求文字

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="wrap_content" 
android:gravity="bottom" 
android:layout_gravity="bottom" 
android:background="#cfd8dc" 
android:layout_height="wrap_content"> 

<ImageButton 
    android:id="@+id/send" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentRight="true" 
    android:src="@android:drawable/ic_menu_send" /> 

<EditText 
    android:id="@+id/text" 
    android:paddingLeft="8dp" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:hint="Type your message" 
    android:layout_alignParentLeft="true" 
    android:layout_toLeftOf="@id/send" /> 
</RelativeLayout> 

This will look like this