android - Adding header to ListView not matching parent in width -


the individual layout files fine (match_parent fills parent), when try set header of listview, behaves differently.

the way see is: button's width, matching parent layout's width, not sure why doesn't work.

actual:

actual]

expected:

xml]

i couldn't code formatting here work here pastebin links them.

header_layout.xml

<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="vertical"    android:paddingbottom="@dimen/activity_vertical_margin"    android:paddingleft="@dimen/activity_horizontal_margin"    android:paddingright="@dimen/activity_horizontal_margin"    android:paddingtop="@dimen/activity_vertical_margin"    tools:context=".mainactivity">      <linearlayout        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:paddingtop="30dp"        android:orientation="vertical"        android:id="@+id/trackingheader">          <linearlayout            android:layout_width="0px"            android:layout_height="0px"            android:focusable="true"            android:focusableintouchmode="true" />          <button            android:id="@+id/start_service"            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:layout_below="@+id/textview"            android:layout_centerhorizontal="true"            android:layout_margintop="10dp"            android:text="begin tracking" />          <button            android:id="@+id/stop_service"            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:layout_below="@+id/start_service"            android:layout_centerhorizontal="true"            android:layout_margintop="10dp"            android:text="cease tracking" />          <textview            android:id="@+id/trackingstatus"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:layout_gravity="center_horizontal"            android:text="large text"            android:textappearance="?android:attr/textappearancelarge"            android:paddingtop="10dp"            android:paddingbottom="10dp" />      </linearlayout> </linearlayout> 

content_main.xml

<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="vertical"    android:paddingbottom="@dimen/activity_vertical_margin"    android:paddingleft="@dimen/activity_horizontal_margin"    android:paddingright="@dimen/activity_horizontal_margin"    android:paddingtop="@dimen/activity_vertical_margin"    tools:context=".mainactivity">      <listview        android:id="@+id/trackinglist"        android:layout_width="wrap_content"        android:layout_height="wrap_content" />  </linearlayout> 

mainactivity.java

    setcontentview(r.layout.activity_main);     trackingheader = (linearlayout) view.inflate(mainactivity.this, r.layout.header_layout, null);     trackinglist = (listview) findviewbyid(r.id.trackinglist);     trackinglist.addheaderview(trackingheader, null, false); 

width of header same listview attribute, need change

android:layout_width="wrap_content" 

to

android:layout_width="match_parent" 

Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -