1

First of all, I want to make a bottom popup, but I don't know how to ignore the layout. I just want to display the gray layout. I'm trying to make it transparent to the white layout and it's not working. I think I must use some code to ignore or something to delete it. I use invisible that will make invisible all the layout.

This my code to make popup

public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

    View rootView = inflater.inflate(R.layout.fragment_account, container, false);

    backbutton1 = (ImageView) rootView.findViewById(R.id.backbutton1);
    btnprofile = (Button) rootView.findViewById(R.id.btnprofile);
    backbutton1.setOnClickListener(onClickListener);
    btnprofile.setOnClickListener(onClickListener);

    return  rootView;

}

private View.OnClickListener onClickListener = new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        if(view == backbutton1) {
            startActivity(new Intent(getActivity().getApplicationContext(), sidemenu.class));
            getActivity().overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right);
        }if(view == btnprofile){

            Bottom_sheet bottom_sheet = new Bottom_sheet();
            bottom_sheet.show(getFragmentManager(), "examplebottomsheet");

        }
    }
};

Bottom_Sheet class:

   public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.popout_chooseimage, container, false);

    Button btnCancel = (Button) view.findViewById(R.id.buttonCancel);
    Button btnRemove = (Button) view.findViewById(R.id.buttonRemove);
    Button btnTake = (Button) view.findViewById(R.id.buttonTake);
    Button btnLibrary = (Button) view.findViewById(R.id.buttonLibrary);

    LinearLayout linear = (LinearLayout) view.findViewById(R.id.bottom_layout);
    linear.setBackgroundResource(0);

    btnCancel.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dismiss();
        }
    });

    return view;
}

Layout:

 <LinearLayout
    android:layout_width="800px"
    android:layout_height="400px"
    android:orientation="vertical"
    android:background="@drawable/button_popout"
    android:layout_marginBottom="10dp"
    android:layout_gravity="center">

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="100px"
        android:background="@drawable/bottom_line">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Change Profile Photo"
            android:fontFamily="@font/seguisb"
            android:textColor="@color/Black"
            android:textSize="30px"
            android:layout_centerInParent="true"/>

    </RelativeLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="100px"
        android:background="@drawable/bottom_line">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Remove Current Photo"
            android:textColor="@color/red"
            android:fontFamily="@font/segoeui"
            android:layout_centerInParent="true"/>
        <Button
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/buttonRemove"
            android:background="@android:color/transparent"/>

    </RelativeLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="100px"
        android:background="@drawable/bottom_line">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Take A Photo"
            android:textColor="@color/active_dots"
            android:fontFamily="@font/segoeui"
            android:layout_centerInParent="true"/>

        <Button
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/buttonTake"
            android:background="@android:color/transparent"/>

    </RelativeLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="100px">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Choose From Library"
            android:textColor="@color/active_dots"
            android:fontFamily="@font/segoeui"
            android:layout_centerInParent="true"/>

        <Button
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/buttonLibrary"
            android:background="@android:color/transparent"/>

    </RelativeLayout>

</LinearLayout>

<LinearLayout
    android:layout_width="800px"
    android:layout_height="wrap_content"
    android:background="@drawable/button_popout"
    android:layout_gravity="center">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="100px">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Cancel"
            android:textSize="40px"
            android:fontFamily="@font/seguibl"
            android:layout_centerInParent="true"/>

        <Button
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/buttonCancel"
            android:background="@android:color/transparent"/>

    </RelativeLayout>

</LinearLayout>

The output will be display

enter image description here

afiq
  • 101
  • 8
  • Which view/widget do you use to show the bottom popup? Change the background of that view – John Le Nov 15 '19 at 10:55
  • @JohnLe can explain to more details – afiq Nov 15 '19 at 11:59
  • 1
    Show us the layout that `Bottom_sheet`. You need to get the root view and set the background to 0 like stated [here](https://stackoverflow.com/questions/6826564/remove-background-drawable-programmatically-in-android). – Alexander Hoffmann Nov 15 '19 at 12:06
  • @AlexanderHoffmann i followed that you give link and not work. before this i try and still same. – afiq Nov 15 '19 at 12:33
  • You can add both your LinearLayouts inside parent layout and that parent layout will have transparent background. can you share `button_popout` code or else whole xml file code for better understanding – nayana bhoj Nov 15 '19 at 12:46
  • @nayanabhoj already put at view == btnprofile – afiq Nov 15 '19 at 12:57

0 Answers0