What I want to do is make a centered box containing some text blurbs and a button to proceed. I was able to get the box centered and not taking up the entire screen by using wrap_content, but the blurbs are several lines long, and the textviews containing them are not showing all the text. Here is what I have:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:background="@color/background"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center"
android:background="@color/content"
android:padding="10dp"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:text="@string/title"
android:textColor="@color/black" />
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="@string/teacher_head"
android:textColor="@color/black" />
<TextView
style="@style/home_blurb"
android:text="@string/teacher_blurb" />
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="@string/student_head"
android:textColor="@color/black" />
<TextView
android:text="@string/student_blurb"
style="@style/home_blurb" />
<Button
android:layout_width="wrap_content"
android:layout_height="0dip"
android:layout_gravity="center"
android:layout_weight="0.1"
android:gravity="center"
android:paddingTop="5dp"
android:text="@string/go_to_app" />
</LinearLayout>
</LinearLayout>
where home_blurb is
<style name="home_blurb" parent="android:TextAppearance">
<item name="android:paddingBottom">5dp</item>
<item name="android:textColor">@color/black</item>
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">fill_parent</item>
<item name="android:layout_weight">1</item>
<item name="android:textSize">12dp</item>
</style>
The inner LinearLayout sets itself to the width of the button, which I’m okay with, but is there any way to make it wide enough to contain all the text without setting particular pixel measurements (like screen percentage in html/css)?
you can use in your second
LinearLayoutso that your layout will remain in center with some space around it every time no matter how much big your text is.
if you want you can give scroll bars to each element you can do it by adding with specific max height for each element then you can do this
android:scrollbars="vertical"and in codetextview.setMovementMethod(new ScrollingMovementMethod());