Android > Layout - include ¿Í º¸À̱⠼û±â±â
µî·ÏÀÏ : 2017-07-05 11:07
Á¶È¸¼ö : 53,092
include ű׸¦ »ç¿ëÇÏ¿© layout À» Æ÷ÇÔÇÒ ¼ö ÀÖ½À´Ï´Ù.
main.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:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="hello" />
<include layout="@layout/actionbar_noti" />
</LinearLayout>
À§ÀÇ ¿¹Á¦Ã³·³ actionbar_noti.xml ÆÄÀÏÀ» include ÇÑ ³»¿ë ÀÔ´Ï´Ù.
actionbar_noti.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/actionbar_notify_pannel"
style="@style/AppBaseTheme"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="100dp"
android:layout_marginRight="20dp"
android:background="@drawable/popup_background"
android:orientation="vertical"
android:paddingTop="10dp"
android:visibility="gone" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:text="@string/notify"
android:textSize="20sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:text="Å×½ºÆ®"
android:textSize="20sp"
android:textStyle="bold" />
</LinearLayout>
À§ÀÇ LinearLayout ÀÇ ID °ªÀº actionbar_notify_pannel ÀÔ´Ï´Ù.
¾Èµå·ÎÀ̵忡¼ ÀÌ LinearLayout À» º¸ÀÓ/¼û±è󸮸¦ ÇÒ ¼ö ÀÖ½À´Ï´Ù.
LinearLayout notiPannel;
notiPannel = (LinearLayout) findViewById(R.id.actionbar_notify_pannel);
if ( showNotiPannel ){
notiPannel.setVisibility(View.GONE);
showNotiPannel = false;
}else{
notiPannel.setVisibility(View.VISIBLE);
showNotiPannel = true;
}
setVisibility ¼Ó¼ºÀ» ÀÌ¿ëÇÏ¸é µË´Ï´Ù.
layout.setVisibility(View.VISIBLE);
ÇØ´ç ºä¸¦ º¸¿©ÁÜ
layout.setVisibility(View.INVISIBLE);
ÇØ´ç ºä¸¦ ¾È º¸¿©ÁÜ(°ø°£Àº Á¸Àç)
layout.setVisibility(View.GONE);
ÇØ´ç ºä¸¦ ¾È º¸¿©ÁÜ(°ø°£¸¶Àú °¨Ãã)
INVISIBLE°ú GONEÀÇ Â÷ÀÌ´Â °ø°£À» º¸¿©ÁÖ´À³Ä ¾È º¸¿©ÁÖ´À³ÄÀÇ Â÷ÀÌÀÌ´Ù.
¿¹¸¦ µé¸é 1 2 3 4 5 ÀÇ ¼ýÀÚ°¡ ÀÖÀ»¶§ 3À» ¼û±â·Á°í ÇÑ´Ù¸é
INVISIBLEÀº 1 2 " " 4 5 ÀÌ·± ½ÄÀ¸·Î 3Àº ¾øÁö¸¸ ÀÚ¸®´Â ³²¾ÆÀÖ°í
GONEÀº 1 2 4 5 ÀÌ·± ½ÄÀ¸·Î 3°ú °ø°£ ¸ðµÎ ¼û±â°Ô µÈ´Ù.