我正在使用约束布局和弹出窗口将我的位图图像放在layout下面。我正在尝试将drawable作为布局的背景,但它不起作用。
这是我的绘画:
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/tutorial_bottom_arrow"
android:gravity="bottom|left">
</bitmap>
这是我的xml布局:
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/popup_parent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/tutorial_arrow_up"
>
我需要这样的东西: Image above layout
答案 0 :(得分:0)
试试这个你可以使用自定义对话框
Dialog myDialog = new Dialog(this);
myDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
myDialog.setContentView(R.layout.custom_dailog_layout);
myDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
myDialog.show();
创建一个custom_dailog_layout文件
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/rl_dialog_container"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:padding="16dp">
<View
android:id="@+id/imagePadding"
android:layout_width="match_parent"
android:layout_height="70dp" />
<LinearLayout
android:id="@+id/round_dialog_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/imagePadding"
android:background="#ffffff"
android:gravity="bottom"
android:orientation="vertical">
<View
android:id="@+id/imagePadding2"
android:layout_width="match_parent"
android:layout_height="70dp" />
<TextView
android:layout_width="match_parent"
android:text="Nilesh"
android:padding="10dp"
android:layout_height="wrap_content" />
</LinearLayout>
<ImageView
android:id="@+id/dialog_image"
android:layout_width="140dp"
android:layout_height="140dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:src="@mipmap/ic_launcher_round" />
</RelativeLayout>