티스토리 뷰

SWDesk/App

[Android] 테두리 만들기

inhae 2021. 11. 28. 10:28

Layout에 border(테두리)를 부여하는 기능

<구성>

  • drawable / famgam_border.xml
  • layout / activity_famgamcontrol.xml

 

 

 

<famgam_border.xml>

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
    android:start = "2dp"
    android:end="2dp"
    android:top="2dp"
    android:bottom="2dp">
    <shape android:shape="rectangle">
        <stroke android:width="2dp"
            android:color = "@color/design_default_color_primary"/>
        <padding
            android:bottom = "-5dp"
            android:top = "10dp"
            android:right = "10dp"
            android:left = "-10dp"/>
        <corners
            android:bottomLeftRadius="5dp"
            android:bottomRightRadius="5dp"
            android:topLeftRadius="5dp"
            android:topRightRadius="5dp" />
    </shape>


</item>

</selector>

<activity_famgamcontrol.xml>

<LinearLayout
    android:id = "@+id/ll_wheelbuttons"
    android:visibility="gone"
    android:orientation="vertical"
    android:paddingBottom="10dp"
    android:background="@drawable/famgam_border"
    app:layout_constraintTop_toBottomOf="@id/ll_ready"
    app:layout_constraintBottom_toTopOf="@id/ll_wheelbuttons"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintVertical_bias="0"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <ImageView
        android:src="@drawable/wheels02"
        android:scaleType="centerInside"
        android:layout_marginLeft="100dp"
        android:layout_marginRight="100dp"
        android:layout_gravity="left"
        android:layout_weight="1"
        android:layout_width="match_parent"
        android:layout_height="0dp"/>

    <LinearLayout
        android:orientation="horizontal"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_weight="2"
        android:layout_width="match_parent"
        android:layout_height="0dp">

        <Button
            android:id = "@+id/btn_fl"
            android:text="F.R.\n(Front Left)"
            android:layout_weight="2"
            android:layout_width="0dp"
            android:layout_height="wrap_content"/>
        <Button
            android:id = "@+id/btn_fr"
            android:text="F.R.\n(Front Right)"
            android:layout_weight="2"
            android:layout_width="0dp"
            android:layout_height="wrap_content"/>
    </LinearLayout>

    <LinearLayout
        android:orientation="horizontal"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_gravity="center_vertical"
        android:layout_weight="2"
        android:layout_width="match_parent"
        android:layout_height="0dp">

        <Button
            android:id = "@+id/btn_rl"
            android:text="R.L.\n(Rear Left)"
            android:layout_weight="2"
            android:layout_width="0dp"
            android:layout_height="wrap_content"/>
        <Button
            android:id = "@+id/btn_rr"
            android:text="R.R.\n(Rear Right)"
            android:layout_weight="2"
            android:layout_width="0dp"
            android:layout_height="wrap_content"/>
    </LinearLayout>

</LinearLayout>
반응형

'SWDesk > App' 카테고리의 다른 글

[Kotlin] Bluetooth Application in Android  (0) 2023.02.14
[Python] msedge 드라이버 및 모듈 설치  (0) 2022.09.03
Testing BLE for FamGam  (0) 2021.11.19
Testing WebAccess  (0) 2021.11.16
RecyclerVieiwTest02  (0) 2021.11.06