Note that there are some explanatory texts on larger screens.

plurals
  1. POset width of linear layout in horizontal scroll view
    text
    copied!<p>I have the following linear layout,and I am setting it as a child to HorizontalScrollView</p> <p>File menu.xml</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/menu" android:orientation="vertical" android:background="#2f4f4f" android:layout_width="wrap_content" android:layout_height="fill_parent"&gt; &lt;ListView android:id="@+id/list" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="#2f4f4f" android:cacheColorHint="#2f4f4f" android:scrollbars="none"&gt; &lt;/ListView&gt; &lt;/LinearLayout&gt; </code></pre> <p>File : scrollview.xml</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#00ffffff" android:padding="0px" android:layout_margin="0px" android:fadingEdge="none" android:fadingEdgeLength="0px" android:scrollbars="none"&gt; &lt;LinearLayout android:id="@+id/top" android:layout_height="fill_parent" android:layout_width="fill_parent" android:orientation="horizontal" android:background="#ffffffff" android:padding="0px" android:layout_margin="0px"&gt; &lt;/LinearLayout&gt; &lt;/HorizontalScrollView&gt; </code></pre> <p>I am trying to set the width of the linear layout programatically but I am getting ClassCastException.(LinearLayout$LayputParams can't be cast to FrameLayout$LayputParams)</p> <pre><code>LayoutInflater inflater = LayoutInflater.from(this); scrollView = inflater.inflate(R.layout.scrollview_xml, null); setContentView(scrollView); View menu = inflater.inflate(R.layout.menu_xml, null); scrollView.addView(menu); scrollView.getChildAt(0).setLayoutParams(new ViewGroup.LayoutParams(100,100)); </code></pre> <p>How to solve this ?</p>
 

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