Android Layout left and right align in horizontal layout

后端 未结 7 574
傲寒
傲寒 2021-01-03 21:01

I am have a ImageView and a ImageButton. I have them next to each other in a horizontal layout. I am trying to make it so that the image is left aligned on the screen, and t

相关标签:
7条回答
  • 2021-01-03 21:55

    a RelativeLayout would solve your problem with a snap, but if you still insist on using LinearLayout (just because we're badass and do things the hard way), you do it like this:

    Your parent LinearLayout is fill-parent, left-aligned, and horizontally oriented, and contains your ImageView, and another LinearLayout.

    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:gravity="left"
    

    Second LinearLayout is fill-parent, right-aligned, and horizontally oriented, and contains your ImageButton.

    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:gravity="right"
    
    0 讨论(0)
提交回复
热议问题