I'm trying to add linearlayout to scrolview, this is my code, the code is compiling, but it does not show me a new layout
this is the original layout (which I want to add to it)
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/ScrollView01" android:layout_width="match_parent" android:layout_height="wrap_content" android:scrollbars="vertical" android:layout_margin="15dp" android:layout_marginTop="15dp"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:paddingBottom="10dp" android:paddingLeft="10dp" android:paddingRight="10dp" android:id="@+id/ViewHistoryImageLayout"> <ImageView android:id="@+id/HistoryImage" android:layout_width="match_parent" android:layout_height="0dip" android:layout_weight="0.76" android:gravity="center" android:padding="10dp" android:src="@drawable/upload" android:contentDescription="@string/HistoryImage"/> <TextView android:id="@+id/TranslatedText" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="0.12" android:paddingBottom="10dp" android:paddingLeft="10dp" android:paddingRight="10dp" android:text="@string/translateImageButton" /> </LinearLayout>
and this is the layout I want to add several times:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:id="@+id/TranslationMenuLayout" > <TextView android:id="@+id/textView1" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Medium Text" android:textAppearance="?android:attr/textAppearanceMedium" /> <RatingBar android:id="@+id/ratingBar1" android:layout_width="match_parent" android:layout_height="wrap_content" android:numStars="5" /> <TextView android:id="@+id/textView2" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="TextView" /> </LinearLayout>
and java code to add a new layout:
setContentView(R.layout.activity_view_history_image); ScrollView sv = new ScrollView(this); LayoutInflater inflater = (LayoutInflater) getSystemService( Context.LAYOUT_INFLATER_SERVICE ); View ll = inflater.inflate(R.layout.translation_menu, null); sv.addView(ll);
The code compiles fine and the application works, but nothing happens. Is there a problem with one of the .xml files?
Tnx
source share