In this Android tip, I am going to show you to make a layout scrollable. When you place many elements in an interface or you have many lines of text in a TextView, some elements or part of the text will be invisible as the size of the screen is not big enough to view all elements or text. This problem can be solved by making the layout scrollable to allow the user to scroll the layout and see the rest elements or text.
<?xml version="1.0" encoding="utf-8"?>
<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:orientation="vertical"
android:background="@drawable/backstylelogin"
>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:id="@+id/relative1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#ffffff"
>
<TextView
android:id="@+id/txtdes"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dip"
/>
<RadioGroup
android:id="@+id/radioips"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<RadioButton
android:id="@+id/radiopublicip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/radio_publicip"
android:checked="true"
/>
<RadioButton
android:id="@+id/radiolocalip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/radio_localip"
/>
</RadioGroup>
<Button
android:id="@+id/btok"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="saveConfig"
android:layout_gravity="center"
android:text="@string/bt_ok"
android:background="@drawable/state"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:textColor="#ffffff"
android:layout_marginTop="30dip"
/>
</LinearLayout>
</ScrollView>
</RelativeLayout>
Posted by: Dara | post date: 06-04-2014 | Subject: Android Apps Development
|
This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.