Foggy day
Android(java) - Activity popup(background dim) 본문
sample video
1. popup_activity_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:gravity="center"
android:orientation="vertical">
<FrameLayout
android:layout_width="300dp"
android:layout_height="400dp"
android:background="@color/white">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Activity Popup"
android:textColor="@color/black"
android:textSize="30dp" />
<TextView
android:id="@+id/tvOK"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_gravity="bottom"
android:background="#FFE0E0E0"
android:gravity="center"
android:text="OK"
android:textColor="@color/black"
android:textSize="20dp" />
</FrameLayout>
</LinearLayout>
2. ShowPopup.java
public class ShowPopup extends AppCompatActivity {
private PopupActivityLayoutBinding b;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
b = PopupActivityLayoutBinding.inflate(getLayoutInflater());
setContentView(b.getRoot());
//If you want to fix orientation, input this code
try {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
} catch (IllegalStateException ignore) {
}
b.tvOK.setOnClickListener(view -> finish());
}
}
3. PopupLayoutActivity
class PopupLayoutActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_popup_layout)
tvShowPopup.setOnClickListener {
startActivity(Intent(this, ShowPopup::class.java))
}
}
}
'Android' 카테고리의 다른 글
Android(안드로이드) - EventBus Example (0) | 2021.03.10 |
---|---|
Android(java) - exoplayer2 (0) | 2021.03.05 |
Android(java) - Depending on seekBar progress num, change view size using BottomSheet (0) | 2021.03.04 |
Android - Arraylist sort, collection sort (0) | 2021.02.23 |
Android - MediaPlayer with surfaceView (0) | 2021.02.17 |