How to make the layout scrollable?
That's edit form in My application, there's one button left after "Simpan Perubahan" button. How to make my form scrollable and make the last button visible and clickable?
I do not know much about layouts.
code :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:text="ID Objek"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<EditText
android:id="@+id/tv_obj_id"
android:editable="false"
android:singleLine="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<TextView
android:text="Nama Objek"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<EditText
android:id="@+id/tv_obj_nama"
android:editable="true"
android:singleLine="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<TextView
android:text="Detail Objek"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<EditText
android:id="@+id/tv_obj_det"
android:editable="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<TextView
android:text="Koordinat Objek"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<TextView
android:text="Longitude"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<EditText
android:id="@+id/tv_obj_long"
android:editable="true"
android:singleLine="true"
android:inputType="numberDecimal"
开发者_JAVA百科 android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<TextView
android:text="Latitude"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<EditText
android:id="@+id/tv_obj_lat"
android:editable="true"
android:singleLine="true"
android:inputType="numberDecimal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<Button
android:id="@+id/btn_obj_submit"
android:text="Simpan Perubahan"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<Button
android:id="@+id/btn_obj_back"
android:text="Simpan Perubahan"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
What should i do to my xml file?
Your layout should look like
<LinearLayout vertical>
<ScrollView>
<LinearLayout vertical>
... here are your fields ...
</LinearLayout>
</ScrollView>
<LinearLayout horizontal>
... here are your buttons ...
</LinearLayout>
</LinearLayout>
Use ScrollView component in the xml. example
You can make List.builder or listview or use scrollable layout using scroll widget in flutter. below is a code you can customized according to your need i did it with List.builder
List litems = ["1","2","3","4"];
return Scaffold(
backgroundColor: Colors.grey[200],
body: Padding(
padding: const EdgeInsets.all(18.0),
child: Column(
children: [
Padding(
padding: const EdgeInsets.fromLTRB(10.0, 0.0, 0.0, 18.0),
child: Align(
alignment: Alignment.topLeft,
child: ListTile(
leading: Row(
children: [
Text(
"LeaderBoard",
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.black,
fontSize: 30),
),
Icon(
Icons.trending_up,
size: 30,
),
],
),
),
),
),
Padding(
padding: const EdgeInsets.all(20.0),
child: Row(
children: [
Expanded(
child: Align(
alignment: Alignment.topLeft,
child: Text(
"Person",
)),
),
Align(
alignment: Alignment.topRight,
child: Text(
"Score",
)),
],
),
),
Expanded(
child: new ListView.builder(
itemCount: litems.length,
itemBuilder: (BuildContext context, int index) {
return new Card(
color: Colors.white,
child: ListTile(
leading: Text(litems[index]),
title: Text(litems[index]),
),
);
}),
),
],
),
),
);
} }
精彩评论