实现选择登录的方式
展示的,上一个跳转你可随意
<?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