小编Pie*_*rre的帖子

BottomSheetDialog透明背景

我想显示一个比屏幕宽度宽的底部对话框.

例如,Nexus 9上的Google Play音乐分享选项.

Nexus 9上的Google Play音乐分享选项

你知道如何实现这个目标吗?

现在我刚刚尝试减少工作表内容的宽度,但背景仍然在屏幕宽度并显示白色背景.

一些代码:

的build.gradle

compile 'com.android.support:design:23.3.0'
Run Code Online (Sandbox Code Playgroud)

主要活动

@Override
protected void onCreate(Bundle savedInstanceState) {
    ...

    mBottomSheetDialog = new BottomSheetDialog(this);
    mBottomSheetDialog.setContentView(R.layout.sheet_test);
    mBottomSheetDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
        @Override
        public void onDismiss(DialogInterface dialog) {
            mBottomSheetDialog = null;
        }
    });
    mBottomSheetDialog.show();
}
Run Code Online (Sandbox Code Playgroud)

sheet_test

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="100dp"
    android:layout_height="match_parent"
    android:orientation="vertical">

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

        <TextView
            style="@style/TextAppearance.AppCompat.Body1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="16dp"
            android:text="Some Text"
            android:textColor="@color/colorPrimary" />

        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="#ddd" />

        <TextView
            style="@style/TextAppearance.AppCompat.Body1"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_margin="16dp"
            android:text="Some Text" />

        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="#ddd" />

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

android

23
推荐指数
12
解决办法
2万
查看次数

如何在PercentRelativeLayout中使用layout_aspectRatio?

我尝试在视图上实现16:9的宽高比PercentRelativeLayout.

所以我把这行放在build.gradle文件中: compile 'com.android.support:design:23.0.1'

我用这个布局:

<android.support.percent.PercentRelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <ImageView
        android:layout_width="match_parent"
        app:layout_aspectRatio="178%"
        android:scaleType="centerCrop"/>

</android.support.percent.PercentRelativeLayout>
Run Code Online (Sandbox Code Playgroud)

问题:

  • Android Studio警告我:'layout_height' should be defined为了ImageView.
  • 当我运行我的项目时,我得到了:Error:(15) No resource identifier found for attribute 'layout_aspectRatio'.

那有什么不对?

android android-layout android-constraintlayout android-percentrelativelayout

13
推荐指数
3
解决办法
8653
查看次数

谷歌键盘搞砸了我的自定义范围

好吧,我尝试构建一个富文本编辑器.我有一些按钮来格式化我的可编辑文本(粗体,斜体,URL等).
我使用谷歌键盘启用了所有文本更正选项(设置 > 语言和输入 > 谷歌键盘 > 文本更正).

我做以下事情:

在我EditText,我写了一些文字.
文本

我选择它并用SPAN_EXCLUSIVE_EXCLUSIVE(33)作为标志应用粗体.
选定的文字
在此输入图像描述

然后,我将光标移动到最后.
光标在最后

最后,我在文本的末尾添加了文本.添加的文字应该没有粗体.
粗体文字

好的,这是问题所在.我的大胆旗帜已经改变......为什么!?

这是一些日志:

D/ContentUtils: beforeTextChanged: start  end  span             flags
D/ContentUtils: beforeTextChanged: 0      7    ChangeWatcher    8388626
D/ContentUtils: beforeTextChanged: 0      7    ChangeWatcher    6553618
D/ContentUtils: beforeTextChanged: 0      7    TextKeyListener  18
D/ContentUtils: beforeTextChanged: 0      7    SpanController   18
D/ContentUtils: beforeTextChanged: 7      7    START            546
D/ContentUtils: beforeTextChanged: 7      7    END              34
D/ContentUtils: beforeTextChanged: 0      7    SpellCheckSpan   33
D/ContentUtils: beforeTextChanged: 0      7    CustomBoldSpan   33

D/ContentUtils: onTextChaghed
D/ContentUtils: …
Run Code Online (Sandbox Code Playgroud)

android android-virtual-keyboard

7
推荐指数
1
解决办法
130
查看次数

如何在视图中应用材料设计规格的宽高比?

我正在CardView为我的应用程序设计一个富媒体标题.

我尝试做这样的事情:

来自谷歌材料设计规范的富媒体标题

根据谷歌材料设计规范,图片应该有16:9的宽高比:

Google富媒体标头规范

所以,我的问题,如何实现这个(代码或XML)?

如果我使用定义的大小,它将不是真正的16:9宽高比,我将不得不处理所有屏幕尺寸和方向的许多资源文件.

否则,我没有成功的代码,因为在设置大小onBindViewHolder(...),getWidth()对我的看法回报0.

任何的想法 ?

android aspect-ratio android-layout material-design android-cardview

4
推荐指数
1
解决办法
3634
查看次数

服务器端使用DataTable进行excel导出

我有一个带服务器端处理的DataTables.在服务器端,我有函数从ajax请求中检索过滤器并从数据库中获取数据.

现在我希望导出数据到带有过滤器的excel文件中.

我假设我必须在服务器端设计一个excel文件创建者并通过HTTP响应发送文件.

我想使用已经定义的函数来处理导出请求.

我的问题是:如何将DataTables过滤器的格式与ajax请求中的格式一样发送到我的服务器?

javascript java datatables

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