首先我们试试不用九点PNG为TextView设置背景图片,XML参数如下: <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/green"/> 最终效果如下: 可以看到,由于图片的宽度不足以填满整个屏幕的宽度,整张图片被均匀地拉伸了。 这种效果非常差,用户肯定是...
Nine-Patch【.9】图片的使用和普通的png图片使用一样。在XML文件中对制作好的Nine-Patch【.9】图片进行使用,重新运行程序,结果如下图:
首先我们试试不用九点PNG为TextView设置背景图片,XML参数如下: <TextViewandroid:layout_width="match_parent"android:layout_height="wrap_content"android:background="@drawable/green"/> 最终效果如下: 可以看到,由于图片的宽度不足以填满整个屏幕的宽度,整张图片被均匀地拉伸了。 这种效果非常差,用户肯定是不能...
Android为制作9Patch图片提供了draw9patch工具,该工具位于Android SDK安装路径的tools目录下,进入该目录双击draw9patch.bat文件,即可启动该工具。 在xml文件中可以使用nine-patch作为根节点创建NinePatchDrawable。nine-patch的节点属性有两个 src:引用的点九图片 dither:是否对位图进行抖动处理 说下NinePatchDrawable的两种...
Nine-Patch图片是一种经过特殊处理的png图片,能够指定图片的哪些区域可以被拉伸而哪些区域不可以。 普通图片被拉伸时的缺陷 有如下xml文件,其中子LinearLayout的背景图片设置成一个名为chat的png图片: <?xml version="1.0" encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/androi...
<?xml version="1.0"encoding="utf-8"?> <LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <ImageView android:layout_width="100dp" ...
2.2 编写mainactivity.xml: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/activity_main" android:layout_width="match_parent" android:layout_height="match_parent...
2.2 编写mainactivity.xml: <?xml version="1.0" encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:id="@+id/activity_main"android:layout_width="match_parent"android:layout_height="match_parent"android...
XML例子 这儿有意向布局xml的例子示范怎么添加一个Nine-Patch图像在两个按钮上(NinePatch图像被保存为res/drawable/my_button_background.9.png) Draw 9-patch工具: 下面是快速指导创建一个Nine-patch图片用Draw9-patch工具,你需要准备你想创建NinePatch的图片。
接下来我们将打开我们主要活动的activity_my_first9_patch_app_main.xml文件,并将在代码中创建一个按钮。整个Button代码看起来像下面的代码片段: <Buttonid="@+id/btnninepatch"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentTop="true"android:layout_centerHori...