layout_gravity in LinearLayout

 ̄綄美尐妖づ 提交于 2019-11-27 19:26:39
Cristian

That's not the way in which android:layout_gravity works. Both, left and center_horizontal parameters work only when the android:orientation is vertical. To achieve what you want, you better use RelativeLayout:

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

        <ImageView   
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_marginLeft="5dip"/>

        <TextView 
        android:layout_height="wrap_content" 
        android:layout_width="wrap_content"  
        android:layout_centerHorizontal="true"
        android:textColor="#ffffff"/>
  </RelativeLayout>    
android:layout_marginLeft="5dip"

should be (dp not dip)

android:layout_marginLeft="5dp"
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!