ビュー構成画面-2の使用
17300 ワード
基地局リンク1
ビュー間隔の設定
-ビューの間隔とpaddingプロパティに設定
-
○visible:画面に表示を出力する
○非表示:画面に出力しない
§画面はよく見えませんが、位置を占めています
○gone:画面に出力しない
§設置後、座席も取らない
例)
targetView.visibility = View.VISIBLE
}
invisibleBtn.setOnClickListener {
targetView.visibility = View.INVISIBLE
}
ビュー間隔の設定
-ビューの間隔とpaddingプロパティに設定
- 'margin은 뷰와 뷰 사이의 간격이고 padding은 뷰의 콘텐츠와 테주리 사이
- margin과 padding 속성을 이용하면 네 방향 모두 같은 크기로 설정 된다
○ 만약 한 반향만 하고 싶으면….
§ paddingTop, paddingBottom, paddingLeft, paddingRight
§ layout_marginTop, layout_marginBottom, layout_marginLeft, layout_marginRight
○ 을 이용
- 예시)
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="50dp"
android:text="Button6(PaddingTop)"
android:backgroundTint="#0000ff"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="90dp"
android:text="Button7(layout_marginLeft by 90)"
android:backgroundTint="#f000ff"
/>
ビューを表示するかどうかを設定-
visibility 속성은 뷰가 화면을 출력되어야 하는지 설정한다 -
可視性の値は...です.○visible:画面に表示を出力する
○非表示:画面に出力しない
§画面はよく見えませんが、位置を占めています
○gone:画面に出力しない
§設置後、座席も取らない
例)
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button1"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button2"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button3"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button1"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button2"
android:visibility="invisible"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button3"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button1"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button2"
android:visibility="gone"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button3"/>
</LinearLayout>
- 위 예시 코드 결과를 보면 중간 Button 2를 invisible를 했다
○ 화면에 안보임
- 오른쪽 Button 2를 gone으로 했는데 흔적도 없이 사라짐
- 만약 XML이 아닌 코드에서 visibility 속성을 사용하고 싶으면….
visibleBtn.setOnClickListener {targetView.visibility = View.VISIBLE
}
invisibleBtn.setOnClickListener {
targetView.visibility = View.INVISIBLE
}
Reference
この問題について(ビュー構成画面-2の使用), 我々は、より多くの情報をここで見つけました https://velog.io/@stefanob11/뷰를-이용한-화면-구성-2テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol