Achieving rounded corners on Android views is relatively straightforward. Under res/drawable, an xml file can be used for creating this style to be applied to a view. rounded_corners.xml <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <!-- View background color --> <solid android:color="#FFF" > </solid> <!-- View border color and width --> <stroke android:width="3dp" android:color="#FFF" > </stroke> <!-- If padding is desired --> <padding android:left="4dp" android:top="4dp" android:right="4dp" android:bottom="4dp" > </padding> <!-- Corner radius --> <corners android:radius="10dp" > </corners> </shape> After creating this xml file, it could be applied to a view to achieve rounded corners like so: <RelativeLayout ..... ..... > <LinearLayout android:layout_width="match_parent" android:id="@+id/home_layout" android:orientation="vertical" android:layout_height="wrap_content" android:background="@drawable/rounded_corners" android:layout_marginRight="15dp" android:layout_marginLeft="15dp" android:layout_marginTop="15dp" android:layout_marginBottom="15dp" > </RelativeLayout> The above code created this rounded expandable listview as seen in the screenshot below. The margins applied in android:layout_margin allowed a red border surrounding the listview as specified by its parent layout - the LinearLayout as seen above. The main view's (RelativeLayout) android:background supplied the rich red background facilitated by the 15dp margins on its child LinearLayout view. After some investigation, rounded corners on Webviews doesn't seem possible, at least not with the same ease of effort as it can be for other views. To achieve the similar look to the listview, it would have to be accomplished in CSS.
<style > body { font-size: 110%; padding: 2.5%; margin: 2.5%; background-color: #FFF; border-style: solid; border-width: 4px; border-color: #FFF; border-radius: 25px; } html { background-color: #D90B0B; } </style>
0 Comments
|
AuthorExploring Android and mobile web design, security, and development. Archives
March 2021
Categories |