My android application has two imagebut开发者_开发知识库tons side by side of equal lenght. They fill a line. I turn my phone but imagebuttons is not filling the line. Even if the phone rotate How do I displaying correctly? Thanks
Use the weight property of the linear layout. Put both the button in a liner layout, specify layout_width = odp and weight=1 for both the button. The weight elements allows you to specify the ratio of the width each element will take . Here is a sample
<LinearLayout android:id="@+id/linearLayout1" android:layout_height="wrap_content"                    
  android:layout_alignParentBottom="true" android:layout_width="fill_parent">
  <Button android:text="Button" android:id="@+id/button1" 
    android:layout_height="wrap_content" android:layout_width="0dp"
    android:layout_weight="1">
  </Button>
  <Button android:text="Button" android:id="@+id/button2"
    android:layout_height="wrap_content" android:layout_weight="1"
    android:layout_width="0dp">
  </Button>
</LinearLayout> 
Edit: the sample is for a button , but you can use it for an image button too
Put both the buttons in TableRow & check after rotation if it works as expected.
Make sure you have width set to "fill_parent" and the weights adjusted correctly if you are using horizontal layout.
You can also, in onCreate, set the width of the image buttons manually.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论