Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid ListView inside RelativeLayout trick
    primarykey
    data
    text
    <p>I came to the point, where in my RelativeLayout have to be two TextViews and one ExpandableListView. After long conversation I decided to show pictures in order for you to see how layout behaves itself.</p> <p>There are snapshots. The first one is when ExpandableListView is NOT Expanded: </p> <p><img src="https://i.stack.imgur.com/3UY9W.png" alt="enter image description here"></p> <p>But when I`m trying to expand this ExpandableListView I see the following:</p> <p><img src="https://i.stack.imgur.com/pzEdY.png" alt="enter image description here"></p> <p>We can see only little part of expanded list and the color of it is the same as the color of next TextView. Why is it so? My goal is to see whole expanded ExpandableListView.</p> <p>The code of xml:</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" &gt; &lt;ScrollView android:id="@+id/scrollView1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:background="#000000" &gt; &lt;LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#00ff00" &gt; &lt;TextView android:id="@+id/user" android:layout_width="match_parent" android:layout_height="100dp" android:paddingLeft="3dp" android:text="Top User" android:textColor="#111111" android:background="#eeeeee" android:textSize="22dp" /&gt; &lt;ExpandableListView android:id="@+id/elvMain" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" &gt; &lt;/ExpandableListView&gt; &lt;TextView android:id="@+id/about" android:layout_width="match_parent" android:layout_height="100dp" android:text="Bottom About" android:textColor="#6f6f6f" android:textSize="24dp" android:textStyle="bold" /&gt; &lt;/LinearLayout&gt; &lt;/ScrollView&gt; </code></pre> <p></p> <p>And the code of Activity:</p> <pre><code>public class IngredientsActivity extends Activity { private ArrayList&lt;Ingredient&gt; ingredients; private Bitmap bitmap; private final String TAG = "IngredientsActivity"; public void onCreate (Bundle bundle) { super.onCreate(bundle); setContentView(R.layout.ingredients_layout); //ingredients = (ArrayList)getIntent().getSerializableExtra("ingredients"); //bitmap = (Bitmap)getIntent().getParcelableExtra("bitmap"); prepareIngredients(); //preparing ExpandableListView children TextView user = (TextView)findViewById(R.id.user); TextView about = (TextView)findViewById(R.id.about); user.setText("Albert Einstein"); about.setText("Albert Einstein (play /ˈælbərt ˈaɪnstaɪn/; German: [ˈalbɐt ˈaɪnʃtaɪn] ( listen); 14 March 1879 – 18 April 1955) was a German theoretical physicist who developed the theory of general relativity, effecting a revolution in physics. For thisfor his services to theoretical physics, and especially for his discovery of the law of the photoelectric effect.[5] The latter was pivotal in establishing quantum theory within physics."); } private void prepareIngredients() { SimpleExpandableListAdapter adapter; final ExpandableListView list = (ExpandableListView)findViewById(R.id.elvMain); ArrayList&lt;Map&lt;String, String&gt;&gt; groupData = new ArrayList&lt;Map&lt;String, String&gt;&gt;(); Map m = new HashMap&lt;String, String&gt;(); m.put("groupName", "Datas"); groupData.add(m); String groupFrom[] = new String[] {"groupName"}; int groupTo[] = new int[] {R.id.groupname}; ArrayList&lt;ArrayList&lt;Map&lt;String, String&gt;&gt;&gt; childData = new ArrayList&lt;ArrayList&lt;Map&lt;String, String&gt;&gt;&gt;(); ArrayList&lt;Map&lt;String, String&gt;&gt; childDataItem = new ArrayList&lt;Map&lt;String, String&gt;&gt;(); for (Ingredient i : ingredients) { Log.d(TAG, "Ingridient: " + i); Map&lt;String, String&gt; m1 = new HashMap&lt;String, String&gt;(); StringBuilder ingredientsString = new StringBuilder(); String v = i.getValue(); if (!v.equals("null")) { ingredientsString.append("- " + i.getName() + " " + v + i.getType()); } else { ingredientsString.append("- " + i.getName() + " " + i.getType()); } m1.put("levelTwoCat", ingredientsString.toString()); childDataItem.add(m1); } childData.add(childDataItem); String childFrom[] = new String[] {"levelTwoCat"}; int childTo[] = new int[] {R.id.ingredients_second_layer_text}; adapter = new SimpleExpandableListAdapter ( this, groupData, R.layout.ingredients_first_layer, groupFrom, groupTo, childData, R.layout.ingredients_second_layer, childFrom, childTo); list.setAdapter(adapter); } </code></pre> <p>The question is the same. How to force ExpandableListView expand in this layout? Now it is not expanded as it has to be. (See the snapshots at the top).</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.
 

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