文章标题

实现选择登录的方式

这里写图片描述

展示的,上一个跳转你可随意

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#ffffff">

    <LinearLayout
        android:layout_marginTop="10dp"
        android:layout_width="match_parent"
        android:layout_height="50dp">
        <ImageView
            android:src="@drawable/shouji"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:layout_marginLeft="140dp"/>
        <TextView
            android:textSize="18sp"
            android:layout_width="80dp"
            android:layout_height="50dp"
            android:gravity="center"
            android:text="QQ登陆" />
    </LinearLayout>
    <TextView
        android:background="#ffffff"
        android:layout_width="match_parent"
        android:layout_height="5dp" />
    <TextView
        android:layout_width="match_parent"
        android:layout_height="2dp"
        android:background="#f2f2f2"/>
    <TextView
        android:background="#ffffff"
        android:layout_width="match_parent"
        android:layout_height="5dp" />
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="50dp">
        <ImageView
            android:src="@drawable/qq"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:layout_marginLeft="140dp"/>
        <TextView
            android:textSize="18sp"
            android:layout_width="80dp"
            android:layout_height="50dp"
            android:gravity="center"
            android:text="QQ登陆" />
    </LinearLayout>
    <TextView
        android:background="#ffffff"
        android:layout_width="match_parent"
        android:layout_height="5dp" />
    <TextView
        android:layout_width="match_parent"
        android:layout_height="2dp"
        android:background="#f2f2f2"/>
    <TextView
        android:background="#ffffff"
        android:layout_width="match_parent"
        android:layout_height="5dp" />
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="50dp">
        <ImageView
            android:src="@drawable/weibo"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:layout_marginLeft="140dp"/>
        <TextView
            android:textSize="18sp"
            android:layout_width="80dp"
            android:layout_height="50dp"
            android:gravity="center"
            android:text=" 微博登陆" />
    </LinearLayout>
    <TextView
        android:background="#ffffff"
        android:layout_width="match_parent"
        android:layout_height="5dp" />
    <TextView
        android:layout_width="match_parent"
        android:layout_height="10dp"
        android:background="#f2f2f2"/>
    <TextView
        android:text="取消"
        android:textSize="19sp"
        android:gravity="center"
        android:layout_width="match_parent"
        android:layout_height="50dp" />


</LinearLayout>

主要的代码

public class MainActivity extends AppCompatActivity {

    /**
     *
     * 选择登录的方式
     *
     * @param savedInstanceState
     */
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button but = (Button) findViewById(R.id.but);
        but.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Dialog bottomDialog = new Dialog(MainActivity.this, R.style.BottomDialog);
                View contentView = LayoutInflater.from(MainActivity.this).inflate(R.layout.dialog_content_normal, null);
                bottomDialog.setContentView(contentView);
                ViewGroup.LayoutParams layoutParams = contentView.getLayoutParams();
                layoutParams.width = getResources().getDisplayMetrics().widthPixels;
                contentView.setLayoutParams(layoutParams);
                bottomDialog.getWindow().setGravity(Gravity.BOTTOM);
                bottomDialog.getWindow().setWindowAnimations(R.style.BottomDialog_Animation);
                bottomDialog.show();
            }
        });

    }
}

还有一个anim,里面设置的属性。可以在github上看,实现以上效果除了这个BottomDialog,还有一个把activity改变成窗口,也可以实现。
https://github.com/MarshalZane/ButDlog

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值