Skip to main content

Custom Button trong Android

Trong android các control đều thuộc lớp View. Như TextView, Button, EditText, . . . .Các bạn có thể tùy chình hình dạng, trang trí giao diện cho các control này như ý muốn.
Hôm này Học Lập Trình sẽ huớng dẫn các bạn 1 cách tùy chỉnh giao diện cho các control 1 cách đơn giản là include file .xml vào cho background để điều chỉnh giao diện.
Đầu tiên các bạn tạo 1 file .xml trong thư mục draw để tùy chỉnh giao diện.
Chuột phải vào thư mục Draw -> New -> File XML
Đặt tên dinhdang.xml
Thêm code sau vào:
<shape android:shape="rectangle" xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- Set màu nền -->
    <solid android:color="#FACC2E">
    </solid>
    <!-- đặt thuộc tính màu và độ rộng của đường viền -->
    <stroke android:color="#0101DF" android:width="3dp">
    </stroke>
    <!-- các thuộc tính căn chỉnh -->
    <padding android:bottom="10dp" android:left="10dp" android:right="10dp" android:top="10dp">
    </padding>
    <!-- và đây là bán kính đường tròn ở 4 góc -->
    <corners android:radius="400dp">
    </corners>
</shape>
Ở màng hình chính bạn thêm thuộc tính android:background="@drawable/duongvien"

Và xêm kết quả

Comments

Popular posts from this blog

Socket Android Client to PC Server C#

Using AsynCallback C# Android Client connect Server C# Source code:  http://ow.ly/OlXj309O1mj c# socket multi client, socket c# example, socket server c#, socket c# tutorial, asynchronous socket in c#, c# socket multiple clients, c# socket server multiple clients, Download source code:  Click Here

Bài tập thuật toán C/C++ Và Tuyển tập đề thi olympic

Gồm: +  Các thuật toán của Lê Minh Hoàng + Tuyển tập các đề thi olympic tin học sinh viên Link down: Tại đây

Cross Platform Mobile App: Demo shop with flutter

Cross Platform Mobile App: Demo shop with flutter So cool framework from google <3  Demo:  Demo Code console.print("hello")