Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grid Layout Width Issue

I have been developing an app for which I also need to handle the UI stuff too.

Heres my XML:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
  <GridLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:columnCount="2" >
    <ImageView />
    <TextView />
    .
    .
  </GridLayout>
</ScrollView>

Now the problem is the width of the right column. It is exceeding the devices' width. For example the name of the mobile which has an attribute of android:layout_gravity set as Center. But its not working as expected as you can see in the screenshot below:

Device Screenshot

What should I be using to keep the width with in limits as the text is dynamic.

like image 536
Umayr Avatar asked Oct 20 '25 06:10

Umayr


1 Answers

I had a similar problem using a GridLayout with fill_horizontal. The solution for me was to set android:layout_width="0dp" so you might want to try that for all views in your second column.

Source

like image 184
Algorithm and Blues Avatar answered Oct 22 '25 22:10

Algorithm and Blues



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!