HorizontalScrollView Tutorial
This view is used to make scroll able group view in Horizontal Direction.
< ?xml version="1.0" encoding="utf-8"?>
< LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
< HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content">
< LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
< android.support.v7.widget.CardView
android:layout_width="300dp"
android:layout_height="400dp"
app:cardCornerRadius="5dp"
app:cardMaxElevation="@dimen/cardview_compat_inset_shadow"
app:cardBackgroundColor="@color/colorAccent"
app:cardUseCompatPadding="true">
< ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="10dp"
android:scaleType="center"
android:src="@drawable/se" />
< /android.support.v7.widget.CardView>
< android.support.v7.widget.CardView
android:layout_width="300dp"
android:layout_height="400dp"
app:cardBackgroundColor="@color/colorAccent"
app:cardCornerRadius="5dp"
app:cardMaxElevation="@dimen/cardview_compat_inset_shadow"
app:cardUseCompatPadding="true">
< ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="10dp"
android:scaleType="center"
android:src="@drawable/bhmm" />
< /android.support.v7.widget.CardView>
< android.support.v7.widget.CardView
android:layout_width="300dp"
app:cardBackgroundColor="@color/colorAccent"
android:layout_height="400dp"
app:cardCornerRadius="5dp"
app:cardMaxElevation="@dimen/cardview_compat_inset_shadow"
app:cardUseCompatPadding="true">
< ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="10dp"
android:scaleType="center"
android:src="@drawable/bmm" />
< /android.support.v7.widget.CardView>
< android.support.v7.widget.CardView
android:layout_width="300dp"
app:cardBackgroundColor="@color/colorAccent"
android:layout_height="400dp"
app:cardCornerRadius="5dp"
app:cardMaxElevation="@dimen/cardview_compat_inset_shadow"
app:cardUseCompatPadding="true">
< ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="10dp"
android:scaleType="center"
android:src="@drawable/brmm" />
< /android.support.v7.widget.CardView>
< android.support.v7.widget.CardView
android:layout_width="300dp"
app:cardBackgroundColor="@color/colorAccent"
android:layout_height="400dp"
app:cardCornerRadius="5dp"
app:cardMaxElevation="@dimen/cardview_compat_inset_shadow"
app:cardUseCompatPadding="true">
< ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="10dp"
android:scaleType="center"
android:src="@drawable/cm" />
< /android.support.v7.widget.CardView>
< android.support.v7.widget.CardView
android:layout_width="300dp"
app:cardBackgroundColor="@color/colorAccent"
android:layout_height="400dp"
app:cardCornerRadius="5dp"
app:cardMaxElevation="@dimen/cardview_compat_inset_shadow"
app:cardUseCompatPadding="true">
< ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="10dp"
android:scaleType="center"
android:src="@drawable/cmm" />
< /android.support.v7.widget.CardView>
< android.support.v7.widget.CardView
android:layout_width="300dp"
app:cardBackgroundColor="@color/colorAccent"
android:layout_height="400dp"
app:cardCornerRadius="5dp"
app:cardMaxElevation="@dimen/cardview_compat_inset_shadow"
app:cardUseCompatPadding="true">
< ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="10dp"
android:scaleType="center"
android:src="@drawable/lcmm" />
< /android.support.v7.widget.CardView>
< /LinearLayout>
< /HorizontalScrollView>
< /LinearLayout>
package example.com.uidemo;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class GalleryActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_gallery);
}
}
< ?xml version="1.0" encoding="utf-8"?>
< resources>
< color name="colorPrimary">#900C3F
< color name="colorPrimaryDark">#581845
< color name="colorAccent">#C70039
< /resources>
< resources>
< !-- Base application theme. -->
< style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
< !-- Customize your theme here. -->
< item name="colorPrimary">@color/colorPrimary
< item name="colorPrimaryDark">@color/colorPrimaryDark
< item name="colorAccent">@color/colorAccent
< /style>
< /resources>
1 comment:
thanks for sharing the informative post with us. it's really very beneficial for us.
Android training in Chandigarh
Post a Comment