반응형
LinearLayout에 모서리 반경을 적용하는 방법
테두리가 둥근 레이아웃을 만들고 싶습니다. 에 특정 크기의 반경을 어떻게 적용 할 수 LinearLayout
있습니까?
드로어 블 폴더에 XML 파일을 만들 수 있습니다. 예를 들어,shape.xml
에서 shape.xml
:
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid
android:color="#888888" >
</solid>
<stroke
android:width="2dp"
android:color="#C4CDE0" >
</stroke>
<padding
android:left="5dp"
android:top="5dp"
android:right="5dp"
android:bottom="5dp" >
</padding>
<corners
android:radius="11dp" >
</corners>
</shape>
<corner>
태그는 특정 질문입니다.
필요에 따라 변경하십시오.
그리고 당신의 whatever_layout_name.xml
:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_margin="5dp"
android:background="@drawable/shape" >
</LinearLayout>
이것이 제가 보통 앱에서하는 일입니다. 도움이 되었기를 바랍니다....
당신은 사용하는 것이 모양 드로어 블을 레이아웃의 배경으로하고 CornerRadius를 설정합니다. 자세한 자습서는 이 블로그 를 확인하십시오.
나열한 것
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="300dp"
android:gravity="center"
android:layout_height="300dp"
android:layout_centerInParent="true"
android:background="@drawable/rounded_edge">
</LinearLayout>
드로어 블 폴더 rounded_edge.xml
<shape
xmlns:android="http://schemas.android.com/apk/res/android">
<solid
android:color="@android:color/darker_gray">
</solid>
<stroke
android:width="0dp"
android:color="#424242">
</stroke>
<corners
android:topLeftRadius="100dip"
android:topRightRadius="100dip"
android:bottomLeftRadius="100dip"
android:bottomRightRadius="100dip">
</corners>
</shape>
프로그래밍 방식으로 반경이있는 배경을 LinearLayout 또는 임의의 뷰로 설정하려면 이것을 시도하십시오.
private Drawable getDrawableWithRadius() {
GradientDrawable gradientDrawable = new GradientDrawable();
gradientDrawable.setCornerRadii(new float[]{20, 20, 20, 20, 20, 20, 20, 20});
gradientDrawable.setColor(Color.RED);
return gradientDrawable;
}
LinearLayout layout = new LinearLayout(this);
layout.setBackground(getDrawableWithRadius());
참고URL : https://stackoverflow.com/questions/10074249/how-to-apply-corner-radius-to-linearlayout
반응형
'development' 카테고리의 다른 글
jquery로 링크에서 html 텍스트 변경 (0) | 2020.08.07 |
---|---|
jQuery에서 "드래깅"을 감지 할 수 있습니까? (0) | 2020.08.07 |
div에 HTML 삽입 (0) | 2020.08.07 |
jQuery 다중 ID 선택기 (0) | 2020.08.07 |
htaccess를 사용하여 모두 index.php로 리디렉션 (0) | 2020.08.07 |