GoodieBag / ProtractorView

A semicircular seekbar view for selecting angle from 0° to 180° :sparkles:
MIT License
217 stars 35 forks source link

Start arc from left to right #2

Open SaranyaSanmugam opened 6 years ago

SaranyaSanmugam commented 6 years ago

Couldn't set the arc starting point from left to right

hirenderswami commented 6 years ago

hello.... i found a way to starting point from both side left to right and right to left.... you have to follow this... xml file <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/Rl">

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/txt"
        android:inputType="number"
        android:imeOptions="actionDone"
        android:hint="Number"/>

    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/txt"
        android:text="right"
        android:id="@+id/but"/>
    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/but"
        android:text="left"
        android:id="@+id/but1"/>

    <com.goodiebag.protractorview.ProtractorView
        android:layout_width="wrap_content"
        android:layout_below="@+id/but1"
        android:layout_height="wrap_content"
        app:arcColor="#00000000"
        app:arcProgressColor="#00ff0000"
        app:tickColor="#606060"
        android:id="@+id/Protractor"
        app:tickProgressColor="#ff8929"
        app:textColor="#00000000"
        app:textProgressColor="#00000000"
        app:tickIntervals="2"
        app:tickLength="20dp"
        app:progressWidth="10dp"
        app:thumb="@drawable/progres"
        app:ticksBetweenLabel="one"
        app:roundEdges="true" />

    <com.goodiebag.protractorview.ProtractorView
        android:layout_width="wrap_content"
        android:layout_below="@+id/but1"
        android:layout_height="wrap_content"
        app:arcColor="#00000000"
        app:arcProgressColor="#00ff0000"
        app:tickColor="#ff8929"
        android:id="@+id/Protractor1"
        android:visibility="gone"
        app:tickProgressColor="#606060"
        app:textColor="#00000000"
        app:textProgressColor="#00000000"
        app:tickIntervals="2"
        app:tickLength="20dp"
        app:progressWidth="10dp"
        app:thumb="@drawable/progres"
        app:ticksBetweenLabel="one"
        app:roundEdges="true" />

</RelativeLayout>

java file cord....

public class MainActivity extends AppCompatActivity {

ProtractorView protractorView,protractorView1;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    final EditText editText = (EditText) findViewById(R.id.txt);

    Button right = (Button) findViewById(R.id.but);
    Button left = (Button) findViewById(R.id.but1);

    right.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            protractorView1.setVisibility(View.GONE);
            protractorView.setVisibility(View.VISIBLE);

            int ng = Integer.parseInt(editText.getText().toString());

            protractorView.setAngle(ng);

        }
    });

    left.setOnClickListener(new View.OnClickListener() {
        @TargetApi(Build.VERSION_CODES.M)
        @RequiresApi(api = Build.VERSION_CODES.M)
        @Override
        public void onClick(View view) {

            int ng = Integer.parseInt(editText.getText().toString());
            protractorView.setVisibility(View.GONE);
            protractorView1.setVisibility(View.VISIBLE);

            protractorView1.setAngle(180-ng);

        }
    });

    protractorView = (ProtractorView) findViewById(R.id.Protractor);

    protractorView1 = (ProtractorView) findViewById(R.id.Protractor1);

//you can remove this cord if you want to move youe seekbar protractorView.setEnabled(false); protractorView1.setEnabled(false);

}

}

i hop it help you....