QMUI Android 圆角按钮使用 QMUIRoundButton

导读:本篇文章讲解 QMUI Android 圆角按钮使用 QMUIRoundButton,希望对大家有帮助,欢迎收藏,转发!站点地址:www.bmabk.com

源代码:依然是使用QMUIWindowInsetLayout 视图,加上QMUITopBarLayout的栏栏,然后只上一个按钮,按钮是QMUI里

QMUIRoundButton有圆角的。

老规据先上效果图:这是我理想要的。

QMUI Android 圆角按钮使用 QMUIRoundButton

activity_button.xml :QMUIWindowInsetLayout 的视图加QMUITopBarLayout, 然后再上圆角:

<?xml version="1.0" encoding="utf-8"?>
<com.qmuiteam.qmui.widget.QMUIWindowInsetLayout 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:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".ButtonActivity">

    <com.qmuiteam.qmui.widget.QMUITopBarLayout
        android:id="@+id/topbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        android:background="@color/app_color_theme_4">
    </com.qmuiteam.qmui.widget.QMUITopBarLayout>

    <com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButton
        android:id="@+id/button_showDefaultDialog"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:onClick="onClickShowDefaultDialog"
        android:paddingBottom="10dp"
        android:paddingLeft="16dp"
        android:paddingRight="16dp"
        android:paddingTop="10dp"
        android:layout_marginTop="20dp"
        android:layout_marginBottom="20dp"
        android:text="圆角按钮 显示"
        app:qmui_isRadiusAdjustBounds="true" />

</com.qmuiteam.qmui.widget.QMUIWindowInsetLayout>

ButtonActivity .class:沉浸式栏一定要有这句话,QMUIStatusBarHelper.translucent(this); 然后用butterknife这个方式重新设置视图。


public class ButtonActivity extends Activity {
    @BindView(R.id.topbar)
    QMUITopBarLayout mTopBar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        setContentView(R.layout.activity_button);

        View root = LayoutInflater.from(this).inflate(R.layout.activity_button, null);
        ButterKnife.bind(this, root);
        //沉浸式状态栏
        QMUIStatusBarHelper.translucent(this);
        setContentView(root);
        initTopBar();
    }

    private void initTopBar() {
        mTopBar.addLeftBackImageButton().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
                overridePendingTransition(R.anim.slide_still, R.anim.slide_out_right);
            }
        });
        mTopBar.setTitle("沉浸式状态栏示例");
    }

    public void onClickShowDefaultDialog(View view) { }



}

 

上效果图:看左边的按钮 ,哈哈,笑shi我了,我也不知道为啥了,我想要的效果图应该如右边好好待着在主视图内的。而不是乱跑的。困惑中…..

 

QMUI Android 圆角按钮使用 QMUIRoundButton

按钮问题:原因是按钮上边距设置过小,本来是要改成:?att/qmui_topbar_heigh,但是是还小,暂时将按钮的外边顶距直接改:

android:layout_marginTop="10dp"改成 android:layout_marginTop="100dp"。

最后运行效果图,差不多跟demo一样了。看了一下demo加了一个ScrollView滚动视图,里面再放一个LinearLayout,

QMUI Android 圆角按钮使用 QMUIRoundButton

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/101682.html

(0)
小半的头像小半

相关推荐

极客之音——专业性很强的中文编程技术网站,欢迎收藏到浏览器,订阅我们!