5
Когда я пытаюсь добавить свой пользовательский вид в горизонтальное представление прокрутки, оно не отображается. , но такой же пользовательский вид показан в другом макете, таком как относительная и линейная компоновка.Пользовательский вид не показан в виде горизонтальной прокрутки Не работает
layout=new LinearLayout(this);
layout.setBackgroundColor(Color.YELLOW);
layout.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.MATCH_PARENT));
layout.setOrientation(LinearLayout.HORIZONTAL);
l = new PredicateLayout(this);
// l.sendtext(info);
for(int j=0;j<info.length;j++)
{
LinearLayout aa=new LinearLayout(this);
aa.setOrientation(LinearLayout.VERTICAL);
t = new TextView(this);
t.setText(info[j]);
t.setBackgroundColor(Color.GREEN);
t.setTextSize(i);
t.setWidth(screenwidth/2);
aa.addView(t);
l.addView(aa, new PredicateLayout.LayoutParams(0, 0));
}
layout.addView(l);
scroll.addView(layout);
Мой XML выглядит следующим образом
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scroll"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:fillViewport="true"
android:orientation="horizontal"
>
</HorizontalScrollView>
также пытался как этот
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scroll"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:fillViewport="true"
android:orientation="horizontal"
>
<com.test.app.PredicateLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:id="@+id/predicate_layout"
>
</com.omnion.bible.PredicateLayout>
</HorizontalScrollView>
кода выглядят как
test=(PredicateLayout)findViewById(R.id.predicate_layout);
for(int j=0;j<info.length;j++)
{
LinearLayout aa=new LinearLayout(this);
aa.setOrientation(LinearLayout.VERTICAL);
t = new TextView(this);
t.setText(info[j]);
t.setBackgroundColor(Color.GREEN);
t.setTextSize(i);
t.setWidth(screenwidth/2);
aa.addView(t);
test.addView(aa, new PredicateLayout.LayoutParams(0, 0));
}
Может ли один помочь мне. Спасибо заранее.
, если вы хотите создать пользовательский просмотр вам необходимо добавить вид в макете .. – Janmejoy