Shape
圆角矩形shape:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- rectangle表示为矩形 -->
<!-- 填充的颜色 -->
<solid android:color="#FAFAFA" />
<!-- 边框的颜色和粗细 -->
<stroke
android:width="1dp"
android:color="#FAFAFA" />
<!-- android:radius 圆角的半径 -->
<corners android:radius="26dp" />
</shape>
RadionButton选中/未选中状态:
radiobutton_selector.xml
<!--seletor-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/ic_artboard_pen_press" android:state_checked="true" />
<item android:drawable="@drawable/ic_artboard_pen_normal" android:state_checked="false"/>
</selector>
设置
android:background="@drawable/ic_artboard_pen_selector"
android:button="@null"
popupwindow显示在view的上方
PopupWindow popupWindow = getPopupWindow();
int[] point = new int[2];
v.getLocationOnScreen(point);
// Get the View's(the one that was clicked in the Fragment) location
popupWindow.showAsDropDown(v,0,-mContentView.getMeasuredHeight()-v.getMeasuredHeight());
private PopupWindow getPopupWindow() {
PopupWindow popupWindow = new PopupWindow();
mContentView = getLayoutInflater().inflate(R.layout.layout_popupwindow, null);
popupWindow.setContentView(mContentView);
mContentView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
popupWindow.setHeight(mContentView.getMeasuredHeight());
popupWindow.setWidth(mContentView.getMeasuredWidth());
return popupWindow;
}
popupwindow的shotAtLocation方法:
主要依据gravity里确定位置(在屏幕中):
popupWindow.showAtLocation(v,Gravity.CENTER,0,0);//在屏幕中间显示
popupWindow.showAtLocation(v,Gravity.TOP,0,0);//在屏幕上访显示