Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to center contents of ListFragment
    primarykey
    data
    text
    <p>I have a simple layout :</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_gravity="center_vertical|center_horizontal" android:orientation="horizontal" &gt; &lt;fragment class="my.test.package.CitiesFragment" android:id="@+id/cities" android:layout_weight="4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical|center_horizontal" /&gt; //.... &lt;/LinearLayout&gt; </code></pre> <p>to the left you can see i have a listfragment that i populate it with cities. Listfragment consists of simple custom adapter:</p> <pre><code>setListAdapter(new CitiesArrayAdapter&lt;String&gt;(getActivity(), R.layout.city_list_item, citiesArrayList)); </code></pre> <p>and the city_list_item.xml is:</p> <pre><code>&lt;my.test.package.VerticalTextView xmlns:android="http://schemas.android.com/apk/res/android" style="@style/verticalTextStyle" android:id="@+id/VerticalTextView" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center_horizontal|center_vertical" android:layout_gravity="center_horizontal|center_vertical" android:background="@android:color/black" android:textColor="@android:color/white" /&gt; </code></pre> <p>VerticalTextView class was taken from this website. the code is here: <a href="https://stackoverflow.com/questions/11435170/android-vertical-textview-with-image-next-to-it/11493549#1149354">VerticalTextView class</a></p> <p>This is what i have so far: <img src="https://i.stack.imgur.com/fdnIs.jpg" alt="enter image description here"></p> <p>As you can see from pic the cities are left aligned. How can I center those cities ??? this is driving me nuts!</p> <p>***** FOUND THE PROBLEM: its in the verticaltextview class: canvas.translate( getCompoundPaddingLeft(), getExtendedPaddingTop() );**</p> <p>getCompoundPaddingLeft right top bottom always return 30 , and the layout gets messed up. Anybody knows why?????????? or how to fix??</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload