scrollview

Android Hide ScrollBar in ScrollView

By default android comes with a scroll bar for scrolling across up and down , but in some specific application we may need to hide the scroll bar and still we should be able to scroll down. So far that kind of application here is the trickĀ  to hide the seek bar.

xml file

[sourcecode language="xml"]
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/LinearLayout01"
android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<ScrollView android:id="@+id/ScrollView01"
android:layout_width="wrap_content" android:layout_height="100px">
<LinearLayout android:id="@+id/LinearLayout02"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical">
<Button android:id="@+id/Button01" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="But1"></Button>
<Button android:id="@+id/Button02" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="But2"></Button>
<Button android:id="@+id/Button03" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="But3"></Button>
</LinearLayout>
</ScrollView>
</LinearLayout>
[/sourcecode]

Java file

[sourcecode language="java"]
public class HideScrollBarExample extends Activity {

@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);

ScrollView sView = (ScrollView)findViewById(R.id.ScrollView01);
// Hide the Scollbar
sView.setVerticalScrollBarEnabled(false);
sView.setHorizontalScrollBarEnabled(false);
}
}
[/sourcecode]

Android HorizontalScrollview Example

In android, we can scroll the elements in both horizontal and vertical format. To scroll in Vertical we can use Scrollview, to scroll in horizontal format we need to use HorizontalScrollview.

Android Scrollview Example

We can use this android scrollview example for layouts. By using android scrollview we can add any number of elements to layouts.

Syndicate content