android 9patch背景图片导致的一个文本显示问题

今天在写android程序时遇到了一个奇怪的问题。

一个简单的布局

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <FrameLayout
        android:id="@+id/fl_base_container"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_marginTop="45dp" />

    <FrameLayout
        android:id="@+id/fl_actionbar"
        android:layout_width="fill_parent"
        android:layout_height="48dp"
        android:background="@drawable/headbg">

        <TextView
            android:id="@+id/tv_center"
            android:textColor="@color/white"
            androi
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,我可以为您提供一些基本的步骤来自己设计一张9-Patch片,并应用片为窗体添加一个不失真背景。 1. 首先,您需要打开 Android Studio,并创建一个新的项目。 2. 接下来,您需要创建一个新的 drawable 资源文件夹,用于存放您的 9-Patch 片。您可以右键点击 res 文件夹,选择 New -> Android Resource Directory。 3. 在弹出的对话框中,选择 drawable 作为资源类型,并为资源文件夹命名(例如:drawable-np)。 4. 选中新创建的 drawable-np 文件夹,右键点击选择 New -> Drawable Resource。 5. 在弹出的对话框中,为您的 9-Patch 片命名,并选择文件类型为 9-Patch。 6. 在接下来的编辑器中,您可以为您的 9-Patch 片添加拉伸和内容区域。拉伸区域用于指定背景图片的拉伸部分,而内容区域用于指定背景图片的内容部分。 7. 完成后,保存您的 9-Patch 片。 8. 接下来,您需要在布局文件中将这个 9-Patch 片作为窗体背景进行应用。例如,在您的 activity_main.xml 布局文件中,您可以添加以下代码: ```xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/your_9_patch_image_name" > <!-- Your views here --> </RelativeLayout> ``` 9. 最后,重新运行您的应用程序,您应该可以看到您的窗体现在具有一个不失真的背景。 希望这些步骤可以帮助您自己设计一张9-Patch片,并应用片为窗体添加一个不失真背景。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值