android tablelayout fixed columns - not getting desired results -


i new android development.

i've tried linearlayout , tablelayout.

i need simple fixed scrollable table 3 columns, can't single list rows need...i have listview , listactivity adapter sorted.

basically want:

  • 3 columns fixed widths, adjusting different screen sizes (thus percentages?)
  • the first column has title , should largest. if text exceeds space, ellipsize it
  • the second column price
  • third column icon , should far right
|-----------------------------------------| | title exceeds th....|  $500 | icon | | title fits          | $1000 | icon | | other title              |   $25 | icon | | long title th... | $1200 | icon | |-----------------------------------------| 

this latest xml:

<?xml version="1.0" encoding="utf-8"?> <tablelayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="match_parent">      <tablerow>         <textview             android:id="@+id/title"             android:layout_height="45dip"             android:layout_width="wrap_content"             android:layout_marginright="10dip"             android:layout_weight="6"             android:ellipsize="end"             android:singleline="true"             android:text="a long title is"             android:textsize="24sp" />           <textview             android:id="@+id/price"             android:layout_width="wrap_content"             android:layout_height="45dip"             android:layout_weight="3"             android:layout_marginright="10dip"             android:ellipsize="marquee"             android:singleline="true"             android:text="price"             android:textsize="24sp" />          <imagebutton             android:layout_weight="1"             android:id="@+id/cart"             android:gravity="end"             android:src="@drawable/cart"             android:layout_width="45dp"             android:layout_height="30dp" >         </imagebutton>     </tablerow> </tablelayout> 

the result icon not far right, , title text has not fixed width...

i have searched many questions , tried many things (see layout_weight) doesn't seem work far. thanks.

in table row(or horizontal orientation of linear layout) advised use android:layout_width="0dp" while dealing android:layout_weight

could please try setting layout_width attribute 0dp. think it'd work.


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

datatable - Matlab struct computations -