Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I remember running into a similar issue in one of my own apps.</p> <p>In your <code>getGenericView</code> method, you can use <a href="http://developer.android.com/reference/android/view/View.html#setPadding%28int,%20int,%20int,%20int%29" rel="nofollow">TextView.setPadding</a> to specify the left padding of the text so that it appears further to the right, and is not overlapped by the icon. Since the method sets the padding in pixels (which will vary depending on the screen's density), it is important to convert the pixels to <a href="http://developer.android.com/guide/topics/resources/more-resources.html#Dimension" rel="nofollow">density-independent pixels</a> so that the padding and appearance is standardized from screen to screen.</p> <p>Here's a full example of the method from my own code:</p> <pre><code>public TextView getGenericView() { // Padding values (in pixels) int left = 36; // to avoid being overlapped by the icon int right = 0; // not needed int top = 15; // space out the list a bit more int bottom = top; // space out the list a bit more // Get density of screen to convert px to dp float scale = m_Context.getResources().getDisplayMetrics().density; // Layout parameters for the ExpandableListView AbsListView.LayoutParams lp = new AbsListView.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); TextView textView = new TextView(MyActivity.this); textView.setLayoutParams(lp); // Center the text vertically textView.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT); // Set the text starting position textView.setPadding((int)(left * scale), (int)(top * scale), right, (int)(bottom * scale)); // left, top, right, bottom textView.setTextSize(20); return textView; } </code></pre> <p>If you have multiple ExpandableListViews throughout your app, it may be better to specify the pixel sizes in the your app resources (res/values/dimen.xml) rather than here at the top of <code>getGenericView</code>, so that it is defined (and can be changed) in one place and you can reference it in all the lists.</p> <p>Hope this helps!</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.
    1. VO
      singulars
      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