I want to make a setting activity like as shown in the image. What should be my logic to develop this kind of screen? Please help me, as I am new to android and I want this type of activity. I have tried many solution's but didn't found like the image I have shared with you.
Thanks in advance
but you still want to do your self just do below way.
create below method
public void openBottomSheet() {
View view = getLayoutInflater().inflate(R.layout.bottom_sheet_emp_cov, null);
Spinner spin1 = (Spinner) view.findViewById(R.id.spin1);
Spinner spin2 = (Spinner) view.findViewById(R.id.spin2);
ListView catList = (ListView) view.findViewById(R.id.listItems);
Button btnDone = (Button) view.findViewById(R.id.btnDone);
final Dialog mBottomSheetDialog = new Dialog(RepActivity.this,
R.style.MaterialDialogSheet);
mBottomSheetDialog.setContentView(view);
mBottomSheetDialog.setCancelable(true);
mBottomSheetDialog.getWindow().setLayout(LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
mBottomSheetDialog.getWindow().setGravity(Gravity.BOTTOM);
mBottomSheetDialog.show();
spin1.setAdapter(new ArrayAdapter<String>(RepActivity.this, android.R.layout.simple_dropdown_item_1line, items));
spin2.setAdapter(new ArrayAdapter<String>(RepActivity.this, android.R.layout.simple_dropdown_item_1line, items));
catList.setAdapter(categoryListAdapter);
btnDone.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mBottomSheetDialog.dismiss();
}
});
}
bottom_sheet_emp_cov layout file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/popup_window"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_height"
android:layout_gravity="bottom|center"
android:background="@android:color/white"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
android:background="@color/colorPrimary"
android:orientation="horizontal"
android:paddingLeft="10dip"
android:paddingRight="10dip"
android:weightSum="3">
<LinearLayout
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="2"
android:orientation="horizontal">
<TextView
android:id="@+id/txt_uninstall"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:text="@string/app_name"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/white"
android:textSize="@dimen/font_normal_size" />
</LinearLayout>
<LinearLayout
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center|right"
android:orientation="horizontal">
<Button
android:id="@+id/btnDone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Done" />
</LinearLayout>
</LinearLayout>
<TextView
android:id="@+id/textView13"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dip"
android:text="Select Zone:"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/colorAccent"
android:textSize="@dimen/font_normal_size_small"
android:textStyle="bold" />
<Spinner
android:id="@+id/spin1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dip"
android:layout_marginTop="5dip" />
<View
android:layout_width="match_parent"
android:layout_height="1dip"
android:background="@color/gray" />
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dip"
android:text="Select Region:"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/colorAccent"
android:textSize="@dimen/font_normal_size_small"
android:textStyle="bold" />
<Spinner
android:id="@+id/spin2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dip"
android:layout_marginTop="5dip" />
<View
android:layout_width="match_parent"
android:layout_height="1dip"
android:background="@color/gray" />
<ListView
android:id="@+id/listItems"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dip"
android:layout_marginTop="5dip"
android:choiceMode="singleChoice"
android:divider="@null"
android:dividerHeight="0dp" />
</LinearLayout>
MaterialDialogSheet style
<style name="MaterialDialogSheet" parent="@android:style/Theme.Dialog">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:windowIsFloating">false</item>
<item name="android:windowAnimationStyle">@style/MaterialDialogSheetAnimation</item>
</style>
<style name="MaterialDialogSheetAnimation">
<item name="android:windowEnterAnimation">@anim/popup_show</item>
<item name="android:windowExitAnimation">@anim/popup_hide</item>
</style>
popup_show animation
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:fromYDelta="100%p"
android:toYDelta="0"
android:duration="300"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"/>
</set>
popup_hide animation
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:fromYDelta="0"
android:toYDelta="100%p"
android:duration="300"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"/>
</set>
firstly you need to use this theme for SettingsActivity
to give it transparent background
<style name="Theme.Transparent4" parent="android:Theme">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowDisablePreview">true</item>
</style>
then in your activity you can set the width and height of it if you want it half of the screen you can set the height of it programmatically parent view all take all the screen space then create child layout and the the height of it
contentView.getLayoutParams().height=screenheight/2;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With