Saturday, 15 August 2015

Android ListView width doesn't match parent -



Android ListView width doesn't match parent -

everyone! have problem android app markup. set width in listview within greedlayout "match_parent" , thought in screensize. in implementation listview width matches whole screen size , due left column doesn't fit in screen. tried utilize tablelayout? result same: listview width bigger want , goes out of screen.

please, help! should alter set listview width fit screen size. bellow simplified markup. image of curren result: https://yadi.sk/d/qh9qovfmunqeo (this 1st question , doesn't have plenty reputation add together image within question).

<?xml version="1.0" encoding="utf-8"?> <gridlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.uploadtoserveractivity" android:id="@+id/gridlayoutid" android:columncount='2'> <button android:layout_width="185dp" android:layout_height="70dp" android:text="@string/select_image" android:id="@+id/selectphoto" android:layout_row="0" android:layout_column="0"/> <listview android:id="@+id/listview" android:divider="#b5b5b5" android:background="#c8c8c8" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_row="0" android:layout_column="1"/> </gridlayout>

here layout want build, made help of linear layout horizontal orientation , using it's android:weightsum property :

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" android:weightsum="100"> <button android:id="@+id/selectphoto" android:layout_width="185dp" android:layout_height="70dp" android:text="select image" android:layout_weight="55"/> <listview android:id="@+id/listview" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#c8c8c8" android:divider="#b5b5b5" android:layout_weight="45" /> </linearlayout>

i hope solved problem?

android android-listview android-gridlayout

No comments:

Post a Comment