Показать макет типа подсказки под панелью действий - PullRequest
0 голосов
/ 19 сентября 2018

Привет, я хочу показать свой всплывающий макет внизу панели действий.Но я попытался позиционировать вид на другой вид.

То, что я хотел: enter image description here

И я на самом деле получаю это:

enter image description here

Что я пытался добиться этого.

// Раздуть макет

View filterLayout = getLayoutInflater().inflate(R.layout.tooltip_layout, null);
        filterPopup = new PopupWindow(this);
       /* filterPopup.setWidth(ListPopupWindow.MATCH_PARENT);
        filterPopup.setHeight(ListPopupWindow.WRAP_CONTENT);*/
        filterPopup.setOutsideTouchable(true);
        filterPopup.setContentView(filterLayout);
        filterPopup.setBackgroundDrawable(new BitmapDrawable());
        filterPopup.setFocusable(true);

// Показать макет нижней части панели действий

int[] location = new int[2];
                                                mActivityMainBinding.appBarMain.contentMain.mainContentLayout.getLocationOnScreen(location);
                                                Point point = new Point();
                                                point.x = location[0];
                                                point.y = location[1];

                                                filterPopup.showAtLocation(mActivityMainBinding.appBarMain.toolbar, Gravity.LEFT | Gravity.TOP, point.x, point.y);

// Это мой макет подсказки

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:card_view="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    card_view:cardBackgroundColor="#fffff">

    <android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="15dp">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/color_white"
            android:orientation="vertical"
            android:padding="10dp">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:fontFamily="@font/futura_medium"
                android:text="Have you selected the right location ?"
                android:textColor="@color/colorSection"
                android:textSize="@dimen/text_sizes_medium" />

            <View
                android:layout_width="match_parent"
                android:layout_height="10dp" />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:fontFamily="@font/futura_medium"
                android:lineSpacingExtra="4dp"
                android:text="Your selected location seems to be little far off from your device location"
                android:textColor="@color/colorTextPrimery"
                android:textSize="@dimen/text_sizes_medium" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="10dp"
                android:layout_marginTop="10dp"
                android:gravity="center"
                android:orientation="horizontal">

                <TextView
                    android:id="@+id/text_no_thanks"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:fontFamily="@font/futura_medium"
                    android:gravity="center"
                    android:text="NO THANKS"
                    android:textColor="@color/colorTextPrimery"
                    android:textSize="@dimen/text_sizes_smaller" />

                <View
                    android:layout_width="20dp"
                    android:layout_height="match_parent" />

                <TextView
                    android:id="@+id/text_change_location"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="end"
                    android:background="@drawable/selector_ligt_to_dark_no_radius"
                    android:fontFamily="@font/futura_medium"
                    android:gravity="center"
                    android:padding="6dp"
                    android:text="CHANGE LOCATION"
                    android:textColor="@color/color_white"
                    android:textSize="@dimen/text_sizes_smaller" />
            </LinearLayout>
        </LinearLayout>
    </android.support.v7.widget.CardView>

    <ImageView
        android:layout_width="20dp"
        android:layout_height="20dp"
        android:layout_marginLeft="60dp"
        android:background="@android:color/transparent"
        android:src="@drawable/arrow_white" />

</FrameLayout>

Может кто-нибудь подсказать мне, что я могу сделать для достижения этой цели?Я хочу показать макет представления карты, чтобы выровнять с выравниванием нижней панели действий.

1 Ответ

0 голосов
/ 19 сентября 2018

полное руководство :)

layout_popup.xml

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="130dp"
    android:layout_height="match_parent"
    android:background="#ffffff"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <LinearLayout
            android:id="@+id/expand"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="start">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="50dp"
                android:gravity="center"
                android:paddingLeft="10dp"
                android:text="@string/company"
                android:textAllCaps="true"
                android:textColor="#000000" />

            <ImageButton
                android:layout_width="50dp"
                android:layout_height="50dp"
                android:background="#00000000"
                android:padding="7dp"
                android:scaleType="fitCenter"
                android:src="@drawable/arr" />

        </LinearLayout>

        <net.cachapa.expandablelayout.ExpandableLayout
            android:id="@+id/expandable_recycler_local"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="end"

            app:el_expanded="false">

            <android.support.v7.widget.RecyclerView
                android:id="@+id/rec_company_list"
                android:layout_width="130dp"
                android:layout_height="wrap_content"
                android:background="@drawable/round_shape_edit_text"
                android:nestedScrollingEnabled="false"></android.support.v7.widget.RecyclerView>
        </net.cachapa.expandablelayout.ExpandableLayout>

        <View
            android:layout_width="130dp"
            android:layout_height="2dp"
            android:layout_marginTop="5dp"
            android:background="#12CED5"></View>

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="start">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center"

                android:padding="10dp"
                android:text="@string/line_number"
                android:textAllCaps="true"
                android:textColor="#000000" />
        </LinearLayout>



        <RadioGroup
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="end"
            android:orientation="horizontal"
            android:paddingRight="10dp"
            android:visibility="gone">

            <RadioButton
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"

                android:text="1"
                android:textAllCaps="true"
                android:textSize="18dp"
                android:textStyle="bold"
                ads:buttonTint="#000000" />

            <RadioButton
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"

                android:text="2"
                android:textAllCaps="true"
                android:textSize="18dp"
                android:textStyle="bold"
                ads:buttonTint="#000000" />
        </RadioGroup>

        <Button
            android:layout_width="match_parent"
            android:layout_height="30dp"
            android:layout_marginTop="10dp"
            android:id="@+id/btn_save"
            android:background="@drawable/grd"
            android:text="@string/save"
            android:textColor="#ffffff" />
    </LinearLayout>
</ScrollView>

затем в коде Java

 btnSettings.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                PopupWindow window = new PopupWindow(HomeActivity.this);
                window.setFocusable(true);
                window.setContentView(view1);
                window.showAsDropDown(view);
                linearLayout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        if (expandableLayout.isExpanded()) {
                            expandableLayout.collapse();
                        } else {
                            expandableLayout.expand();
                        }
                    }
                });

            }
        });
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...