3
Я хочу создать Scrollview с кодом,Android студии добавить Scrollview программно не прокручивается
Я создал Scrollview и LinearLayout, но не прокручивается вниз,
Что я должен сделать для способена для прокрутки
вы можете найти скриншот следующую ссылку http://screencast.com/t/bbDcDWoScPyM
Вот активность XML
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/rlt"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
tools:context="com.test.test.test">
</RelativeLayout>
и вот код Java
RelativeLayout lL = (RelativeLayout) findViewById(R.id.rlt);
ScrollView sv= new ScrollView(this);//(ScrollView) findViewById(R.id.svScroll);
LinearLayout sahne = new LinearLayout(this);
sahne.setOrientation(LinearLayout.VERTICAL);
txt1.setLayoutParams(new LinearLayout.LayoutParams(textRequireWidth,textRequireHeight));
txt2.setLayoutParams(new LinearLayout.LayoutParams(textRequireWidth,textRequireHeight));
txt3.setLayoutParams(new LinearLayout.LayoutParams(textRequireWidth,textRequireHeight));
txt4.setLayoutParams(new LinearLayout.LayoutParams(textRequireWidth,textRequireHeight));
txt5.setLayoutParams(new LinearLayout.LayoutParams(textRequireWidth,textRequireHeight));
txt6.setLayoutParams(new LinearLayout.LayoutParams(textRequireWidth,textRequireHeight));
txt7.setLayoutParams(new LinearLayout.LayoutParams(textRequireWidth,textRequireHeight));
sahne.addView(txt1);
sahne.addView(txt2);
sahne.addView(txt3);
sahne.addView(txt4);
sahne.addView(txt5);
sahne.addView(txt6);
sahne.addView(txt7);
sahne.addView(btn1);
sv.addView(sahne);
lL.addView(sv);
Вы пытались установить параметры макета на своих 'ScrollView' и' LinearLayout'? – xbakesx
Вы пробовали установить layout_width и layout_height для ScrollView sv и LinearLayout sahne? Я считаю, что эти параметры требуются. – Aster
есть, но не работает –