我試圖創建一個彈出窗口,其中有幾個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