I have 10 vertical TextViews that contain two numbers separated by a line like so.
seatStats2[i].setText(0 + "\n" + 0);
When first made visible these textViews appear fine:
However if I click or longClick any of the ten buttons on screen the textViews stretch to include were the \n character would be on the first line (I tested out different number combinations to confirm this).
The methods for clicking the buttons are not linked to the TextViews in anyway (LongClicking is but both affect it). I'll provide the code for both listeners anyway. textView2 is the array holding the problematic textViews. I wish to maintain the textViews ability to stretch should I put greater numbers in but I want to remove the unnecessary stretching between clicks.
//Creates longClickListener, used for players to sit in or out.
longClickListener = new View.OnLongClickListener()
{
@Override
public boolean onLongClick(View v)
{
if(moveButtonMode)
return false;
for(int i=0; i<10; i++)
{
//Each seat[i] will correspond with each imageButtoni+1
if(v.getId() == (getResources().getIdentifier("imageButton" + (i+1), "id", "en.deco.android.livehud")))
{
//If the seat is empty fill it, place a player in the seat and change the buttons colour to grey and setup stat panel
if(table.seats[i].getState().equals("empty"))
{
seatButton[i].setImageResource(R.drawable.black_seat);
table.seats[i].sit(new Player());
table.incrementOccupiedSeatCount();
seatStats[i].setVisibility(View.VISIBLE);
seatStats2[i].setVisibility(View.VISIBLE);
seatStats[i].setText(table.seats[i].getPlayer().getVpip() + "/" + table.seats[i].getPlayer().getPfr() + "/" + table.seats[i].getPlayer().getHands());
seatStats2[i].setText(table.seats[i].getPlayer().getSteal() + "\n" + table.seats[i].getPlayer().getThreeBet());
}
//If the seat is full, empty it
else
{
seatButton[i].setImageResource(R.drawable.dotted_box);
seatStats[i].setText("");
table.seats[i].sitOut();
table.decrementOccupiedSeatCount();
seatStats[i].setVisibility(View.INVISIBLE);
seatStats2[i].setVisibility(View.INVISIBLE);
}
}
}
return true;
}
};
public void playerClickhandler(View v)
{
if(!moveButtonMode)
{
for(int i = 0; i<10; i++)
{
if(v.getId() == getResources().getIdentifier("imageButton" + (i+1), "id", "en.deco.android.livehud"))
{
if(table.seats[i].getState() == "active")
{
table.seats[i].setState("called");
seatButton[i].setImageResource(R.drawable.green_seat);
}
else if(table.seats[i].getState() == "called")
{
table.seats[i].setState("raised");
seatButton[i].setImageResource(R.drawable.orange_seat);
}
else if(table.seats[i].getState() == "raised")
{
table.seats[i].setState("active");
seatButton[i].setImageResource(R.drawable.grey_seat);
}
}
}
}
else
{
for(int i = 0; i<10; i++)
{
if(v.getId() == getResources().getIdentifier("imageButton" + (i+1), "id", "en.deco.android.livehud"))
{
dealerBtnImage[table.getButtonSeat()].setVisibility(View.INVISIBLE);
table.passButton(i);
dealerBtnImage[table.getButtonSeat()].setVisibility(View.VISIBLE);
moveButtonMode = false;
nextHandButton.setEnabled(true);
}
}
}
}
XML TextView Sample
<TextView android:id="@+id/textView19" android:visibility="invisible" android:background="#000000" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_toRightOf="@+id/imageButton9" android:layout_alignParentTop="true"></TextView>
enter code here