Я пытаюсь создать всплывающее окно с несколькими 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