layout_gravity in LinearLayout

前端 未结 2 731
日久生厌
日久生厌 2020-12-05 05:21

This is my layout:



        
相关标签:
2条回答
  • 2020-12-05 05:49
    android:layout_marginLeft="5dip"
    

    should be (dp not dip)

    android:layout_marginLeft="5dp"
    
    0 讨论(0)
  • 2020-12-05 05:59

    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>    
    
    0 讨论(0)
提交回复
热议问题