小编Jef*_*hou的帖子

无论我尝试什么,AlertDialog 都不会包装内容

这是我的对话框的 xml 文件

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/main"
android:paddingTop="23dp"
android:background="@android:color/white">

<ImageView
    android:id="@+id/officer"
    android:layout_width="47dp"
    android:layout_height="47dp"
    android:layout_marginLeft="24dp"
    android:background="@drawable/officerman"/>
<TextView
    android:id="@+id/text"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Are you sure you want\nto sign out?"
    android:textSize="15.5dp"
    android:textColor="#1C86FF"
    android:layout_marginTop="4dp"
    android:lineSpacingExtra="2dp"
    android:layout_marginLeft="84dp"/>

<LinearLayout
    android:layout_marginTop="20dp"
    android:layout_width="264dp"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:weightSum="1"
    android:layout_below="@id/officer">

    <Button
        android:id="@+id/yes"
        android:layout_width="wrap_content"
        android:layout_weight="0.5"
        android:layout_height="42dp"
        android:background="#1C86FF"
        android:text="Yes"
        android:textAllCaps="false"
        android:textSize="15dp"
        android:textColor="@android:color/white"/>

    <Button
        android:id="@+id/no"
        android:layout_width="wrap_content"
        android:layout_weight="0.5"
        android:layout_height="42dp"
        android:background="#0078FF"
        android:textSize="15dp"
        android:textColor="@android:color/white"
        android:textAllCaps="false"
        android:text="No"/>

</LinearLayout>

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

这是我的java代码

    AlertDialog.Builder build = new AlertDialog.Builder(Login.this);
    View lview = getLayoutInflater().inflate(R.layout.dialog_leave,null);
    build.setView(lview);
    AlertDialog dialog = build.create();
    dialog.show(); …
Run Code Online (Sandbox Code Playgroud)

android android-alertdialog android-dialog

7
推荐指数
3
解决办法
6537
查看次数

Android按钮高程阴影不起作用

我正在尝试制作一个使用高程阴影的按钮,背景图像是我用gmail png登录的.该按钮包含在相对布局中.无论我尝试做什么,高程都不会显示.我尝试过其他论坛问题的解决方案而没有工作.

这是我的按钮代码

<Button
    android:id="@+id/google"
    android:layout_width="270dp"
    android:layout_height="38dp"
    android:layout_marginTop="30dp"
    android:layout_centerHorizontal="true"
    android:background="@drawable/google"
    android:elevation="10dp"
    android:layout_below="@id/slogan"/>
Run Code Online (Sandbox Code Playgroud)

谷歌drawable是我从Adobe XD导出的png图像.有人可以给我一个关于我做错的指针吗?谢谢.

另外,我意识到,如果我将按钮的背景设置为android:color/white,则会出现阴影.所以我认为问题是png可绘制的?高程不适用于png图像吗?有解决方法吗?

android material-design android-elevation

6
推荐指数
1
解决办法
5688
查看次数

删除底部导航视图中图标的填充

我试图将底部导航视图中的图标调低。例如,现在它们像这样按在顶行上。

在这里查看图片

我如何降低图标?我希望它们在底部导航视图中垂直居中。

xml:

<?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"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.jchousurface.mastertrack.homescreen">

<FrameLayout
    android:id="@+id/content"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1">
</FrameLayout>

<android.support.design.widget.BottomNavigationView
    android:id="@+id/navigation"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom"
    android:background="#FFFFFF"
    app:menu="@menu/navigation" />

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

android navigationview bottomnavigationview

5
推荐指数
1
解决办法
2483
查看次数