Android 特定设备上的九个修补程序背景问题
我将下面显示的9-patch图像Android 特定设备上的九个修补程序背景问题,android,nine-patch,Android,Nine Patch,我将下面显示的9-patch图像test.9.png设置为视图的背景,然后将填充重置为0 结果是对称的,正如预期的那样,在我的Nexus 4和Android 4.4.4上,但在我的华为G6-L11和4.3上,我得到的结果如下所示,即图像没有以对称的方式水平延伸 我是做错了还是一只虫子 test.xml test.9.png(6x4像素) 预期结果(Nexus4、Android 4.4.4) 错误结果(华为G6-L11,安卓4.3) 将test.9.png添加到res/drawable nod
test.9.png
设置为视图的背景,然后将填充重置为0
结果是对称的,正如预期的那样,在我的Nexus 4和Android 4.4.4上,但在我的华为G6-L11和4.3上,我得到的结果如下所示,即图像没有以对称的方式水平延伸
我是做错了还是一只虫子
test.xml
test.9.png(6x4像素)
预期结果(Nexus4、Android 4.4.4)
错误结果(华为G6-L11,安卓4.3)
将test.9.png添加到
res/drawable nodpi
文件夹中将test.9.png添加到drawable nodpi文件夹中,查看发生了什么是!如果您愿意,请回答,以便我可以接受。因为在res/drawable nodpi中,
图像不会自动重新缩放到当前配置
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
</LinearLayout>
public class TestFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.test, container, false);
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
view.setBackgroundResource(R.drawable.test);
view.setPadding(0,0,0,0);
}
}