I want to set minumum value in my seekbar android - android

I want my seekbar having values from 33 to 80, I have read in Google, that we cannot set minimum in xml, so I add 33 to progress. But the thing is that my seekbar gets values from 33 to 113(max + 30). Any tips will be valuable for me, thank you.
TextView textView123;
SeekBar seekBar;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_calc);
seekBar = (SeekBar) findViewById(R.id.seekBar1);
textView123 = (TextView) findViewById(R.id.progress);
textView123.setText(seekBar.getProgress() + " ");
seekBar.setOnSeekBarChangeListener(
new OnSeekBarChangeListener() {
int progress = 0;
#Override
public void onProgressChanged(SeekBar seekBar,
int progresValue, boolean fromUser) {
progress = progresValue + 33;
}
#Override
public void onStartTrackingTouch(SeekBar seekBar) {
// Do something here,
}
#Override
public void onStopTrackingTouch(SeekBar arg0) {
// TODO Auto-generated method stub
textView123.setText(progress + " ");
}
});
xml layout
<ImageView
android:id="#+id/background"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="center"
android:src="#drawable/backgroundpic" />
<TextView
android:id="#+id/textView4"
android:layout_width="match_parent"
android:layout_height="240dp"
android:layout_alignParentLeft="true"
android:layout_marginTop="20dp"
android:background="#color/white" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/seekBar1"
android:layout_alignParentLeft="true"
android:layout_marginLeft="14dp"
android:text="Quantity"
android:textAppearance="?android:attr/textAppearanceLarge" />
<SeekBar
android:id="#+id/seekBar1"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/textView4"
android:layout_marginTop="27dp"
android:max="80"
android:progress="1" />
<TextView
android:id="#+id/progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/textView1"
android:layout_alignParentRight="true"
android:layout_marginRight="91dp"
android:text="33"
android:textAppearance="?android:attr/textAppearanceSmall" />
</RelativeLayout>

Simple solution:
Set max to the actual value you want minus the min value you programmatically add in onProgressChanged.
In your case, simply set max to 47 (80 - 33).

Related

Get value of multiple rating bars and set a limit on how many stars can be used

I am working on a project with fragments where I have 4 rating bars (with four stars each) and the user can only use up 10 "stars" combined from all the rating bars.
I am trying to add up the values right now, but even that doesn't work. I want to be able to add up all the values, and then restrict how many values can be set throughout all the ratings.
FragmentRatings.java:
public class FramentRatings extends Fragment{
RatingBar rbStrength, rbIntellect, rbWisdom, rbDexterity;
TextView tvPointSpent;
float pointsS, pointsI, pointsW, pointsD, total;
private SharedPreferences prefs;
#Nullable
#Override
public View onCreateView(LayoutInflater inflater, #Nullable ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_ratings, container, false);
rbStrength = (RatingBar)view.findViewById(R.id.strengthRating);
rbIntellect = (RatingBar)view.findViewById(R.id.intellectRating);
rbWisdom = (RatingBar)view.findViewById(R.id.wisdomRating);
rbDexterity = (RatingBar)view.findViewById(R.id.dexterityRating);
tvPointSpent = (TextView)view.findViewById(R.id.tvPointsSpend);
rbStrength.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
#Override
public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
tvPointSpent.setText(""+rbStrength.getRating());
pointsS = rbStrength.getRating();
}
});
rbIntellect.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
#Override
public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
//tvPointSpent.setText(""+rbIntellect.getRating());
pointsI = rbIntellect.getRating();
}
});
rbWisdom.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
#Override
public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
//tvPointSpent.setText(""+rbStrength.getRating());
pointsW = rbWisdom.getRating();
}
});
rbDexterity.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
#Override
public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
//tvPointSpent.setText(""+rbStrength.getRating());
pointsD = rbDexterity.getRating();
}
});
total = pointsD + pointsI + pointsS + pointsW;
tvPointSpent.setText(""+pointsS);
return view;
}
}
fragment_ratings.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/tvStrength"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/strengthRating"
android:layout_marginEnd="59dp"
android:layout_marginRight="59dp"
android:layout_toLeftOf="#+id/strengthRating"
android:layout_toStartOf="#+id/strengthRating"
android:text="Strength:"
android:textSize="30sp" />
<TextView
android:id="#+id/tvIntellect"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/tvStrength"
android:layout_alignStart="#+id/tvStrength"
android:layout_alignTop="#+id/intellectRating"
android:text="Intellect:"
android:textSize="30sp" />
<TextView
android:id="#+id/tvWisdom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/tvIntellect"
android:layout_alignStart="#+id/tvIntellect"
android:layout_alignTop="#+id/wisdomRating"
android:text="Wisdom:"
android:textSize="30sp" />
<RatingBar
android:id="#+id/strengthRating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="141dp"
android:layout_marginRight="141dp"
android:layout_marginTop="61dp"
android:numStars="4"
android:rating="0"
android:stepSize="1.0"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<RatingBar
android:id="#+id/intellectRating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/strengthRating"
android:layout_alignStart="#+id/strengthRating"
android:layout_below="#+id/strengthRating"
android:layout_marginTop="58dp"
android:numStars="4"
android:rating="0"
android:stepSize="1.0" />
<RatingBar
android:id="#+id/wisdomRating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/intellectRating"
android:layout_alignStart="#+id/intellectRating"
android:layout_below="#+id/intellectRating"
android:layout_marginTop="61dp"
android:numStars="4"
android:rating="0"
android:stepSize="1.0" />
<RatingBar
android:id="#+id/dexterityRating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/wisdomRating"
android:layout_alignRight="#+id/wisdomRating"
android:layout_below="#+id/wisdomRating"
android:layout_marginTop="66dp"
android:numStars="4"
android:rating="0"
android:stepSize="1.0" />
<TextView
android:id="#+id/tvDexterity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/tvIntellect"
android:layout_alignStart="#+id/tvIntellect"
android:layout_alignTop="#+id/dexterityRating"
android:text="Dexterity:"
android:textSize="30sp" />
<TextView
android:id="#+id/tvPoints"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/tvDexterity"
android:layout_alignStart="#+id/tvDexterity"
android:layout_below="#+id/dexterityRating"
android:layout_marginTop="62dp"
android:text="Points left to spend: "
android:textSize="30sp" />
<TextView
android:id="#+id/tvPointsSpend"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/tvPoints"
android:layout_marginLeft="30dp"
android:layout_marginStart="30dp"
android:layout_toEndOf="#+id/tvPoints"
android:layout_toRightOf="#+id/tvPoints"
android:text="10"
android:textSize="30sp" />
</RelativeLayout>
Picture of the rating bars
Might have got the logic wrong but shouldn't the line:
tvPointSpent.setText(""+pointsS);
be:
tvPointSpent.setText(String.valueOf(total));
I am probably very late, But
One quick fix I would suggest is pointsS = ratingBar.getRating();
orpointsS = rating; and like this for rest, since these parameters in the function onRatingChanged(...) are which fetch the changed and final values.

Adjust the size of a shape based on seekbar progress

I currently am trying to use the SeekBar to change the size of a ring: as the value of the SeekBar increases, I would like the size of the ring to increase. However, when I use the code below, the shape size does not change. Does anyone know how to make this work?
public class MainActivity extends Activity {
TextView textview3;
SeekBar tipSeekBar;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tipSeekBar = (SeekBar) findViewById(R.id.seekBar);
tipSeekBar.setOnSeekBarChangeListener(tipSeekBarListener);
}
private OnSeekBarChangeListener tipSeekBarListener = new OnSeekBarChangeListener(){
#Override
public void onProgressChanged(SeekBar arg0, int arg1, boolean arg2) {
TextView textview3 = (TextView) findViewById(R.id.textView3);
textview3.setHeight((int) (tipSeekBar.getProgress()));
textview3.setWidth((int) (tipSeekBar.getProgress()));
}
#Override
public void onStartTrackingTouch(SeekBar arg0) {
TextView textview3 = (TextView) findViewById(R.id.textView3);
textview3.setHeight((int) (tipSeekBar.getProgress()));
textview3.setWidth((int) (tipSeekBar.getProgress()));
}
#Override
public void onStopTrackingTouch(SeekBar arg0) {
TextView textview3 = (TextView) findViewById(R.id.textView3);
textview3.setHeight((int) (tipSeekBar.getProgress()));
textview3.setWidth((int) (tipSeekBar.getProgress()));
}
};
xml file:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
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" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/textView"
android:layout_marginTop="20dp"
android:text="TextView" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="#drawable/circgraya" />
<TextView
android:id="#+id/textView3"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="#drawable/ring_unfilled_gray" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:gravity="center"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<SeekBar
android:id="#+id/seekBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/textView4"
android:layout_toRightOf="#+id/textView"
android:progressDrawable="#drawable/red_scrubber_progress"
android:thumb="#drawable/red_scrubber_control" />
<TextView
android:id="#+id/textView"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/textView4"
android:background="#CC0000"
android:gravity="center"
android:text="10"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#ffffff" />
</RelativeLayout>
Your problem is here...
<TextView
android:id="#+id/textView3"
android:layout_width="200dp" <---
android:layout_height="200dp" <---
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="#drawable/ring_unfilled_gray" />
You've set the size explicitly, so it seems it won't override it as it would min, max(s), and wrapping content.
This works for me (changing the size of the text view via the seek bar that is)...
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content" <---
android:layout_height="wrap_content" <---
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="I'll get bigger soon..." /> <-- notice no background!
However, this is a hack. A text view probably isn't what you want. I didn't use an image because the image isn't important to controlling the height and width of the text view. An image would be more appropriate I believe. I think you'll find, once you get it "working", it might not behave as you would like.
Also -
You could be doing some unnecessary things here. My code that handles the progress change is like so (names changed to mine now)...
...
#Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
if (fromUser) {
mTextView.setHeight(progress);
mTextView.setWidth(progress);
}
}
...
As you can tell I don't...cast an int to an int, getProgress() - I've already got it, or instantiate a new TextView for each change and gesture. You're actually allocating two new TextViews on a gesture; one at the start, and one at the end. You may want to keep a member TextView to hang on to and refer to the Android Docs to know what API methods you're using are doing, the parameters they provide, and their proper usage.

Android allow multi-touch on an activity

I am trying to allow the user to put a ring on the circle on the screen and then press the larger button so that the circle goes to the next ring size.
Everything work fines when no ring is on the screen.
However when a ring it on the screen no other touches are called and the buttons and the seekbar does not work.
I'm new in android and i haven't came across this requirement before. Is there a way I can allow multi-touch gestures on the activity or a way to ignore touches on that specific layout?
XML File
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/White"
android:splitMotionEvents="false"
>
<TextView
android:id="#+id/us"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="#+id/uslbl"
android:padding="#dimen/standard_margin"
android:text="size"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#color/pressed_gemporia" />
<TextView
android:id="#+id/uklbl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/uslbl"
android:padding="#dimen/standard_margin"
android:text="UK Size:"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#color/Black" />
<TextView
android:id="#+id/uk"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/uklbl"
android:layout_alignBottom="#+id/uklbl"
android:layout_toRightOf="#+id/uklbl"
android:padding="#dimen/standard_margin"
android:text="size"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#color/pressed_gemporia" />
<ImageView
android:id="#+id/ci"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" />
<TextView
android:id="#+id/uslbl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_toLeftOf="#+id/uk"
android:gravity="left"
android:padding="#dimen/standard_margin"
android:text="US Size:"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#color/Black" />
<SeekBar
android:id="#+id/seekbar"
android:progressDrawable="#drawable/red_scrubber_progress"
android:thumb="#drawable/red_scrubber_control"
android:max="8"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/divider" />
<View
android:id="#+id/divider"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_alignParentLeft="true"
android:layout_below="#+id/uklbl"
android:layout_marginTop="18dp"
android:background="#color/pressed_gemporia" />
<TextView
android:id="#+id/sizes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:padding="#dimen/standard_margin"
android:layout_below="#+id/seekbar"
android:text="TextView" android:textColor="#color/pressed_gemporia" />
<Button
android:id="#+id/right"
android:layout_width="100dp"
android:textColor="#color/pressed_gemporia"
android:layout_height="wrap_content"
android:background="#color/White"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/left"
android:text="Larger" />
<Button
android:id="#+id/left"
android:layout_width="100dp"
android:background="#color/White"
android:textColor="#color/pressed_gemporia"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:text="Smaller" />
<ImageView
android:id="#+id/ring"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/ci"
android:layout_centerHorizontal="true"
android:src="#drawable/j" />
Java Code
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.ring_sizes);
left = (Button)findViewById(R.id.left);
right = (Button)findViewById(R.id.right);
us = (TextView) findViewById(R.id.us);
uk = (TextView) findViewById(R.id.uk);
ci = (ImageView)findViewById(R.id.ci);
ring = (ImageView)findViewById(R.id.ring);
sizes.add(R.drawable.j);
sizes.add(R.drawable.l);
sizes.add(R.drawable.n);
sizes.add(R.drawable.p);
sizes.add(R.drawable.r);
sizes.add(R.drawable.t);
sizes.add(R.drawable.v);
sizes.add(R.drawable.x);
sizes.add(R.drawable.z);
USsizes.add("5");
USsizes.add("6");
USsizes.add("7");
USsizes.add("8");
USsizes.add("9");
USsizes.add("10");
USsizes.add("11");
USsizes.add("12");
USsizes.add("13");
UKsizes.add("J-K");
UKsizes.add("L-M");
UKsizes.add("N-O");
UKsizes.add("P-Q");
UKsizes.add("R-S");
UKsizes.add("T-U");
UKsizes.add("V-W");
UKsizes.add("X-Y");
UKsizes.add("Z+");
color = (getBaseContext().getResources().getColor(R.color.pressed_gemporia));
value = (TextView) findViewById(R.id.sizes);
seekbar = (SeekBar) findViewById(R.id.seekbar);
seekbar.getProgressDrawable().setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY));
value.setText("UK Size : "+UKsizes.get(0) + " - US Size: " + USsizes.get(0));
setUpViews();
seekbar.setOnSeekBarChangeListener( new OnSeekBarChangeListener()
{
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser)
{
ring.setImageResource(sizes.get(progress));
us.setText(USsizes.get(progress));
uk.setText(UKsizes.get(progress));
counter=progress;
value.setText("UK Size : "+UKsizes.get(progress) + " - US Size: " + USsizes.get(progress));
}
public void onStartTrackingTouch(SeekBar seekBar)
{
// TODO Auto-generated method stub
}
public void onStopTrackingTouch(SeekBar seekBar)
{
// TODO Auto-generated method stub
}
});
}
public void setUpViews(){
ring.setImageResource(sizes.get(counter));
us.setText(USsizes.get(counter));
uk.setText(UKsizes.get(counter));
right.setOnClickListener(new View.OnClickListener()
{
#Override
public void onClick(View view)
{
if(UKsizes.size()>counter+1){
ring.setImageResource(sizes.get(counter+1));
seekbar.setProgress(counter+1);
}
}
});
left.setOnClickListener(new View.OnClickListener()
{
#Override
public void onClick(View view)
{
if(counter!=0){
ring.setImageResource(sizes.get(counter));
seekbar.setProgress(counter-1);
} }
});
}
}
There is a way to ignore touches in particular layout,for that you should add
android:splitMotionEvents="false"
in your layout . You can refer answers from thie following link
https://stackoverflow.com/questions/12777435/disable-multi-finger-touch-in-my-app

How to change the TextView Color on click of a layout in android?

I want to change the background image and TextView Color on click of a layout .The background color is chnaging properly but my textview color is not changing.Here is my XML code :
<RelativeLayout
android:id="#+id/flight_relative"
android:clickable="true"
android:layout_width="match_parent"
android:layout_height="70dp"
android:layout_below="#+id/imgLogo"
android:layout_marginTop="5dp"
android:background="#drawable/button_effect"
android:gravity="center_vertical" >
<TextView
android:id="#+id/flight_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/flight_list_image"
android:layout_marginTop="10dp"
android:layout_toRightOf="#+id/flight_list_image"
android:text="#string/flight_tittle"
android:textColor="#152b72"
android:textSize="15dp"
android:textStyle="bold" />
<TextView
android:id="#+id/content_flight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/flight_content"
android:layout_toRightOf="#+id/flight_list_image"
android:text="#string/flight_content"
android:textColor="#2f2f2f"
android:textSize="10sp" />
<ImageView
android:id="#+id/flight_arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/flight_content"
android:layout_alignParentRight="true"
android:src="#drawable/arrow" />
<ImageView
android:id="#+id/flight_list_image"
android:layout_width="50dip"
android:layout_height="50dip"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:padding="3dip"
android:src="#drawable/flight_icon" />
</RelativeLayout>
Code to chnage the textview color is :
flightRelative = (RelativeLayout )findViewById(R.id.flight_relative);
flightRelative.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View arg0) {
flight = (TextView)findViewById(R.id.flight_content);
flight.setTextColor(Color.WHITE);
}
});
What wrong i am doing please suggest me .For the first time it is not working on second time it is working
You should add this definitely working.I am also check it out...
flightRelative.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View arg0) {
TextView flight = (TextView)findViewById(R.id.flight_content);
flight.setTextColor(Color.parseColor("#FFFFFF"));
}
});
you should use
#Override
public void onClick(View arg0) {
flight = (TextView)flightRelative.findViewById(R.id.flight_content);
flight.setTextColor(Color.WHITE);
}
I believe it should work now.

How to resize TextView with SeekBar's progress (Android)

I'm triying to change the text size of a TextView using a SeekBar, and it's works fine ONLY when i increase the size, when decrease, the "text size" changes well, but the "textview's layout" seems to have the biggest height you put (The text appears in the center of the layout as if has the match_parent property instead of wrap_content).
I tried many combinations of the textview's layout properties (It's in a RelativeLayout)
(H:WRAP_CONT,W:WRAP_CONT / H:MATCH_PAR,W:MATCH_PAR,ALING PARENT TOP TRUE /.....)
Can someone help me??
EDIT: The textview should appear on top
LAYOUT
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/preview_preview"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="#+id/preview_image"
android:layout_width="match_parent"
android:layout_height="match_parent" android:background="#drawable/cuadros_001"/>
<TextView
android:id="#+id/preview_text_top"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="TextView"
android:textColor="#FFFFFF"/>
<TextView
android:id="#+id/preview_text_bottom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="2.5dp"
android:gravity="bottom|center"
android:text="PREVIEW_TEXT_BOTTOM"
android:textColor="#FFFFFF"
android:textSize="25dp" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true"/>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<GridView
android:id="#+id/preview_gridview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/backgroundtransparencia"
android:gravity="center"
android:horizontalSpacing="5dp"
android:numColumns="3"
android:stretchMode="columnWidth"
android:verticalSpacing="10dp" >
</GridView>
</LinearLayout>
<LinearLayout
android:id="#+id/preview_child_2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
</ViewFlipper>
---SEEKBAR--
seekbar_toptext =(SeekBar)findViewById(R.id.seekbar_toptext);
seekbar_toptext.setProgress(40);
seekbar_toptext.incrementProgressBy(05);
seekbar_toptext.setMax(100);
seekbar_toptext.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
int topsize;
public void onStopTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
public void onStartTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
preview_text_top.setTextSize(TypedValue.COMPLEX_UNIT_SP ,progress);
}
});
Thanks in advance.
Try this Code...
I hope this will helps to you...
final TextView t1=new TextView(this);
t1.setText("Hello Android");
final SeekBar sk=(SeekBar) findViewById(R.id.seekBar1);
sk.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
#Override
public void onStopTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
#Override
public void onStartTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
#Override
public void onProgressChanged(SeekBar seekBar, int progress,boolean fromUser) {
// TODO Auto-generated method stub
t1.setTextSize(progress);
Toast.makeText(getApplicationContext(), String.valueOf(progress),Toast.LENGTH_LONG).show();
}
});

Categories

Resources