我有一张图片:
此图像被设置为seekArc的背景(圆环化的搜索栏,找到here)
问题是,当我设置图像时,我已经进入了seekArc视图的背景;它延伸到seekArc的实际弧度;如此
所示XML代码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:seekarc="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<com.triggertrap.seekarc.SeekArc
android:id="@+id/SeekArc1"
android:layout_width="500dp"
android:layout_height="500dp"
android:layout_alignBottom="@+id/hometemp"
android:layout_alignParentRight="true"
android:background="@drawable/largepower"
android:padding="85dp"
seekarc:arcWidth="3dp"
seekarc:max="100"
seekarc:rotation="180"
seekarc:startAngle="30"
seekarc:sweepAngle="300"
seekarc:touchInside="true" />
<com.triggertrap.seekarc.SeekArc
android:id="@+id/SeekArc01"
android:layout_width="500dp"
android:layout_height="500dp"
android:layout_alignLeft="@+id/homepower"
android:layout_alignTop="@+id/SeekArc1"
android:padding="85dp"
seekarc:arcWidth="3dp"
seekarc:max="100"
seekarc:rotation="180"
seekarc:startAngle="30"
seekarc:sweepAngle="300"
seekarc:touchInside="true" />
<ProgressBar
android:id="@+id/hometemp"
style="@style/tallerBarStyle"
android:layout_width="500dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:maxHeight="50dp" />
<Switch
android:id="@+id/homepower"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignTop="@+id/SeekArc01"
android:text="Power" />
</RelativeLayout>
片段代码:
homeFragmentView = viewInflation.inflate(R.layout.homefragment_page,
container, false);
temp = (ProgressBar) homeFragmentView.findViewById(R.id.hometemp);
power = (Switch) homeFragmentView.findViewById(R.id.homepower);
s1 = (SeekArc) homeFragmentView.findViewById(R.id.SeekArc1);
s2 = (SeekArc) homeFragmentView.findViewById(R.id.SeekArc01);
Resources res = homeFragmentView.getResources();
Drawable drawable = res.getDrawable(R.drawable.largepower);
if (drawable.equals(null)) {
Toast.makeText(getActivity().getBaseContext(), "NULL", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(getActivity().getBaseContext(), "NOT NULL", Toast.LENGTH_LONG).show();
s1.setBackground(drawable);
}
让seekArc绕过图像会有什么好方法?
答案 0 :(得分:0)
我通过创建自定义bitmap.xml文件解决了这个问题:
<?xml version="1.0" encoding="utf-8"?>
<bitmap
xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/small"
android:antialias="false"
android:dither="false"
android:filter="false"
android:gravity="center"
android:mipMap="false"
android:tileMode="disabled" />
并将其放在我在res中创建的新文件夹@ drawable-nodpi中。
然后我提到了我需要的手动缩放图像。