我试图创建一个弹出窗口,其中有几个RelativeLayout
,几个TextView
和一个单一的Button
。Android - 弹出式窗口创建和样式
这里的弹出窗口:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/popup_handphone_MainLayout"
android:layout_width="match_parent" android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/popup_handphone_Wrapper"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/popup_handphone_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/popupPhoneMessage"/>
<RelativeLayout
android:id="@+id/popup_handphone_functionalities"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/popup_handphone_text"
android:layout_marginTop="15dp">
<EditText
android:id="@+id/popup_handphone_phoneNumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<EditText
android:id="@+id/popup_handphone_phoneNumberConfirm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/popup_handphone_phoneNumber"
android:layout_marginTop="10dp"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/popup_handphone_phoneNumberConfirm"
android:layout_marginTop="20dp"
android:layout_marginBottom="40dp"/>
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
如何显示它的Activity
?使用LayoutInflater
尝试,但得到了一个错误说它发现View
代替..
代码:
RelativeLayout mainLayout = (RelativeLayout)findViewById(R.id.popup_handphone_MainLayout);
LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
RelativeLayout popupLayoutInflater = inflater.inflate(R.layout.popup_handphone, mainLayout);
//This part here said it needs android.widget.RelativeLayout, but found android.view.View
popupLayout = (RelativeLayout)findViewById(R.layout.popup_handphone);
这是我想要的弹出窗口。灰色的是弹出窗口,其中包含两个TextViews
和一个Button
管理使用此tutorial创建弹出窗口。但是,还有周围的弹出窗口黑色背景像这个
下面是onclick
上TextView
View.OnClickListener phoneReinputHandler = new View.OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(SignupStepTwoActivity.this, PopupHandphone.class);
backDim = (RelativeLayout) findViewById(R.id.bac_dim_layout);
//backDim.setVisibility(View.VISIBLE);
startActivity(intent);
};
如何去除黑啄更新的代码?
你的代码和logcat的是必须在一个回答.. – SSH
烨加入它,忘记它添加 –
你试图让父RelativeLayout的背景作为透明? – Nilabja