Question

I have an image:

Gauge

This image is being set as the background for the seekArc (a circularized seekBar, found here)

The problem is, when I set the image I have made to the background of the seekArc view; it extends past the actual arc of the seekArc; as seen with this screenshot

XML Code:

 <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>

fragment code:

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);
        }

What would be a good method about getting the seekArc to go around the image?

Was it helpful?

Solution

I solved this problem by creating a custom bitmap.xml file:

 <?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" />

and placing it within a new folder @drawable-nodpi that I created in my res.

Then I referred to a manually-scaled image of the size I needed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top