Disable row after click titanium - titanium

what I want to do is this:
I have a tableview and, when I click on a tableviewrow I want this tableviewrow to be disabled so you cannot click it again to fire the event 'click' once again, but I want you to be able to click on any other row from the table.
I've tried this:
e.row.touchEnabled = false;
But it doesn't seems to work.
Hope you can help me.
Thanks ^.^
Here is the code for the TableView
<TableView id="tableBuilding" allowsSelection="true">
<TableViewRow id="row" selectedBackgroundImage = "/images/bt_select_picker.png">
<ImageView id="imgBuilding"/>
<Label id="labBuilding" class="labelScroll" text="Building 01" />
<ImageView id="imgTransparent6" class="opacity"/>
<ImageView id="imgRemove6" class="remove" onClick="edit"/>
<ImageView id="imgHandle6" class="handle" onClick="handle"/>
</TableViewRow>
<TableViewRow id="row" selectedBackgroundImage = "/images/bt_select_picker.png">
<ImageView id="imgBuilding"/>
<Label id="labBuilding" class="labelScroll" text="Building 02" />
<ImageView id="imgTransparent7" class="opacity"/>
<ImageView id="imgRemove7" class="remove" onClick="edit"/>
<ImageView id="imgHandle7" class="handle" onClick="handle"/>
</TableViewRow>
<TableViewRow id="row" selectedBackgroundImage = "/images/bt_select_picker.png">
<ImageView id="imgBuilding"/>
<Label id="labBuilding" class="labelScroll" text="Building 03" />
<ImageView id="imgTransparent8" class="opacity"/>
<ImageView id="imgRemove8" class="remove" onClick="edit"/>
<ImageView id="imgHandle8" class="handle" onClick="handle"/>
</TableViewRow>
<TableViewRow id="row" selectedBackgroundImage = "/images/bt_select_picker.png">
<ImageView id="imgBuilding"/>
<Label id="labBuilding" class="labelScroll" text="Building 04" />
<ImageView id="imgTransparent9" class="opacity"/>
<ImageView id="imgRemove9" class="remove" onClick="edit"/>
<ImageView id="imgHandle9" class="handle" onClick="handle"/>
</TableViewRow>
<TableViewRow id="row" selectedBackgroundImage = "/images/bt_select_picker.png">
<ImageView id="imgBuilding"/>
<Label id="labBuilding" class="labelScroll" text="Building 05" />
<ImageView id="imgTransparent10" class="opacity"/>
<ImageView id="imgRemove10" class="remove" onClick="edit"/>
<ImageView id="imgHandle10" class="handle" onClick="handle"/>
</TableViewRow>
</TableView>
And here is te eventListener
$.tableBuilding.addEventListener('click', function(e) {
e.row.children[0].image = "/images/ic_selectedbuilding.png";
e.row.children[1].color = "white";
e.row.setTouchEnabled = false;
});

Because the tableView is already created use the set method for that propery:
e.row.setTouchEnabled = false;

Related

Problems with MotionLayout OnSwipe (touchRegionId). Can't initiate onClickListener on other elements

I have a youtube-like MotionLayout and I have problems to make it work as I want.
As in the pictures below I want to drag/swipe only on the main_container and not the whole screen (this 2 pictures showing my to states of the MotionLayout) - this is working with touchRegionId.
But I also want to click something in my main_container:
In the end state I want to click play/pause and close
In the start state I want to use my exoplayer and his controls
And my question is how can I achieve that.
This is my end state:
This is my start state:
My motion-scene (only Transition):
<Transition
motion:constraintSetEnd="#+id/end"
motion:constraintSetStart="#id/start"
motion:duration="1000">
<KeyFrameSet>
<KeyAttribute
motion:motionTarget="#+id/close_imageView"
motion:framePosition="90"
android:alpha="0" />
<KeyAttribute
motion:motionTarget="#+id/play_imageView"
motion:framePosition="90"
android:alpha="0" />
<KeyAttribute
motion:motionTarget="#+id/title_textView"
motion:framePosition="95"
android:alpha="0" />
</KeyFrameSet>
<OnSwipe
motion:touchRegionId="#id/main_container"
motion:dragDirection="dragDown"
motion:nestedScrollFlags="disableScroll" />
</Transition>
And my activity_main.xml (without the whole NestedScrollView below the main_container from start state):
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.motion.widget.MotionLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/motion_layout_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutDescription="#xml/activity_main_scene"
tools:context=".MainActivity">
<com.google.android.material.appbar.AppBarLayout
android:id="#+id/appBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:ignore="MissingConstraints">
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar_menu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white"
app:menu="#menu/toolbar_menu">
<ImageView
android:id="#+id/icon"
android:layout_width="60dp"
android:layout_height="55dp"
android:adjustViewBounds="true"
android:background="#drawable/icons8_youtube_192___" />
<TextView
android:id="#+id/youtube_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="YouTubeClone"
android:textColor="#color/black"
android:textSize="20sp"
android:textStyle="bold"
android:gravity="center"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/user_profile_imageview"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_alignParentEnd="true"
android:layout_marginEnd="10dp"
android:src="#drawable/ic_baseline_account_circle_24" />
</RelativeLayout>
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
<androidx.fragment.app.FragmentContainerView
android:id="#+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_above="#+id/bottom_navigation"
app:layout_constraintBottom_toTopOf="#+id/bottom_navigation"
app:layout_constraintTop_toBottomOf="#+id/appBar" />
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="#+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white"
app:itemIconTint="#color/black"
app:itemRippleColor="#color/cardview_dark_background"
app:itemTextColor="#color/black"
app:labelVisibilityMode="labeled"
app:layout_constraintBottom_toBottomOf="parent"
app:menu="#menu/bottom_menu" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/main_container"
android:layout_width="match_parent"
android:layout_height="250dp"
android:background="#color/colorDivider"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.exoplayer2.ui.PlayerView
android:id="#+id/player_main"
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="#android:color/background_dark"
android:scaleType="centerCrop"
app:controller_layout_id="#layout/exoplayer_controller"
app:layout_constraintBottom_toBottomOf="#id/main_container"
app:layout_constraintStart_toStartOf="#id/main_container"
app:layout_constraintTop_toTopOf="#id/main_container"
app:player_layout_id="#layout/exo_player_view"
app:use_controller="true" />
<ProgressBar
android:id="#+id/progress_bar_main"
android:layout_width="60dp"
android:layout_height="60dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="#id/main_container"/>
<ImageView
android:id="#+id/close_imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:alpha="0"
app:layout_constraintBottom_toBottomOf="#id/main_container"
app:layout_constraintEnd_toEndOf="#id/main_container"
app:layout_constraintTop_toTopOf="#id/main_container"
app:srcCompat="#drawable/ic_baseline_close_24"/>
<ImageView
android:id="#+id/play_imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="24dp"
android:alpha="0"
app:layout_constraintBottom_toBottomOf="#+id/close_imageView"
app:layout_constraintEnd_toStartOf="#+id/close_imageView"
app:layout_constraintTop_toTopOf="#+id/close_imageView"
app:srcCompat="#drawable/ic_baseline_play_arrow_24_white"
app:tint="#color/black" />
<TextView
android:id="#+id/title_textView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="12dp"
android:alpha="0"
android:ellipsize="end"
android:maxLines="1"
app:layout_constraintBottom_toBottomOf="#+id/play_imageView"
app:layout_constraintEnd_toStartOf="#+id/play_imageView"
app:layout_constraintStart_toEndOf="#+id/player_main"
app:layout_constraintTop_toTopOf="#+id/play_imageView" />
</androidx.constraintlayout.motion.widget.MotionLayout>

Getting the error while trying to fetch data entered into edit text fields in alert dialog, I have used Kotlin as the language

val mDialogView =
LayoutInflater.from(this).inflate(R.layout.enterupdateaddresslayout, null)
//AlertDialogBuilder
val mBuilder = AlertDialog.Builder(this)
.setView(mDialogView)
.setTitle("Update Delivery Address")
//show Dialog
val mAlertDialog = mBuilder.show()
//click on SAVE Button
mDialogView.findViewById<Button>(R.id.popUpUpdateSaveButton).setOnClickListener {
//get text from Edit Texts of alert layout
val houseNo =
mDialogView.findViewById<EditText>(R.id.popUpHouseNumber).text
Log.d("House Number", "$houseNo")
I am trying to get the data entered into the EditText into the houseNo variable.
when ever that line of code executes, error is being displayed or session is getting logged out.
Below is the enterupdateaddresslayout layout xml code.
I have tried all the tricks but none are working.
Can anyone please help?
The buttons are working fine, it is only the issue with the Edit Text fields.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/cardViewPopUp"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
>
<EditText
android:id="#+id/popUpUpdateHouseNumber"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/enter_house_number"
android:importantForAutofill="no"
android:inputType="number"
android:minHeight="48dp"
tools:ignore="TextContrastCheck"
/>
<EditText
android:id="#+id/popUpUpdateStreetName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/popUpUpdateHouseNumber"
android:hint="#string/enter_street_name"
android:importantForAutofill="no"
android:inputType="text"
android:minHeight="48dp"
tools:ignore="TextContrastCheck"
/>
<EditText
android:id="#+id/popUp_Update_City_Village"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/popUpUpdateStreetName"
android:hint="#string/enter_city_village_name"
android:importantForAutofill="no"
android:inputType="text"
android:minHeight="48dp"
tools:ignore="TextContrastCheck"
/>
<EditText
android:id="#+id/popUp_Update_District"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/popUp_Update_City_Village"
android:hint="#string/enter_district_name"
android:importantForAutofill="no"
android:inputType="text"
android:minHeight="48dp"
tools:ignore="TextContrastCheck"
/>
<EditText
android:id="#+id/popUp_Update_State"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/popUp_Update_District"
android:hint="#string/enter_state_name"
android:importantForAutofill="no"
android:inputType="text"
android:minHeight="48dp"
tools:ignore="TextContrastCheck"
/>
<EditText
android:id="#+id/popUp_Update_PinCode"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/popUp_Update_State"
android:hint="#string/enter_pincode"
android:importantForAutofill="no"
android:inputType="text"
android:minHeight="48dp"
tools:ignore="TextContrastCheck"
/>
<Button
android:id="#+id/popUpUpdateSaveButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/popUp_Update_PinCode"
android:layout_alignParentStart="true"
android:layout_centerHorizontal="true"
android:layout_marginStart="5dp"
android:text="#string/save"
/>
<Button
android:id="#+id/popUpUpdateCancelButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/popUp_Update_PinCode"
android:layout_alignParentEnd="true"
android:layout_centerHorizontal="true"
android:layout_marginEnd="5dp"
android:text="#string/cancel"
/>
</RelativeLayout>

TextView background colour changed by kotlin text, but Button background ignores the same instruction

I want to change the background colours of some textViews and buttons if a boolean (priSec) is false. Their original colours have been set in an .xml file. The following Kotlin text changes the textViews ok, but the buttons (hoopWin1 and hoopWin2) ignore the instructions. How should I correct this?
if(priSec==false){
score1bk.setBackgroundColor(getResources().getColor(R.color.light_brown))
score1.setBackgroundColor(getResources().getColor(R.color.light_green))
p1text.setBackgroundColor(getResources().getColor(R.color.light_brown))
hoopWin1bk.setBackgroundColor(getResources().getColor(R.color.brown))
hoopWin1.setBackgroundColor(getResources().getColor(R.color.green))
score2bk.setBackgroundColor(getResources().getColor(R.color.off_white))
score2.setBackgroundColor(getResources().getColor(R.color.light_pink))
p2text.setBackgroundColor(getResources().getColor(R.color.off_white))
hoopWin2bk.setBackgroundColor(getResources().getColor(R.color.white))
hoopWin2.setBackgroundColor(getResources().getColor(R.color.pink))
}else{} // leave colours as set by activity_clickerscreen.xml
Here is my .xml file:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#B0C0B0"
tools:context=".Clickerscreen">
<TextView
android:id="#+id/p1text"
android:layout_width="160dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:background="#606060"
android:gravity="center_horizontal"
android:text="#string/blue_black"
android:textSize="24sp"
android:textColor="#FFFFFF"
app:layout_constraintEnd_toStartOf="#+id/guideline"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/score1bk" />
<TextView
android:id="#+id/p2text"
android:layout_width="160dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:background="#FFFFC0"
android:gravity="center_horizontal"
android:text="#string/red_yellow"
android:textSize="24sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="#id/guideline"
app:layout_constraintTop_toBottomOf="#+id/score2bk" />
<TextView
android:id="#+id/HoopsDone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginEnd="8dp"
android:text="#string/hoops_done"
android:textSize="34sp"
app:layout_constraintBottom_toTopOf="#id/score1"
app:layout_constraintEnd_toStartOf="#+id/numberOfHoops"
app:layout_constraintHorizontal_bias="0.52"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/numberOfHoops"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="16dp"
android:text="#string/_0"
android:textSize="34sp"
app:layout_constraintBaseline_toBaselineOf="#+id/HoopsDone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/HoopsDone" />
<TextView
android:id="#+id/score1bk"
android:layout_width="160dp"
android:layout_height="120dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:background="#606060"
android:gravity="center_vertical|center_horizontal"
app:layout_constraintBottom_toTopOf="#id/hoopWin1"
app:layout_constraintEnd_toStartOf="#id/guideline"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/HoopsDone" />
<TextView
android:id="#+id/score1"
android:layout_width="120dp"
android:layout_height="80dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:background="#68C0FF"
android:gravity="center_vertical|center_horizontal"
android:textSize="50sp"
app:layout_constraintBottom_toTopOf="#id/hoopWin1"
app:layout_constraintEnd_toStartOf="#id/guideline"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/HoopsDone" />
<TextView
android:id="#+id/score2bk"
android:layout_width="160dp"
android:layout_height="120dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:background="#FFFFC0"
android:gravity="center_vertical|center_horizontal"
app:layout_constraintBaseline_toBaselineOf="#id/score1bk"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="#+id/guideline" />
<TextView
android:id="#+id/score2"
android:layout_width="120dp"
android:layout_height="80dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:background="#FF8080"
android:gravity="center_vertical|center_horizontal"
android:textSize="50sp"
app:layout_constraintBaseline_toBaselineOf="#id/score1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="#+id/guideline" />
<TextView
android:id="#+id/hoopWin1bk"
android:layout_width="160dp"
android:layout_height="160dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:background="#000000"
app:layout_constraintBottom_toTopOf="#+id/cancel"
app:layout_constraintEnd_toStartOf="#+id/guideline"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/score1bk" />
<Button
android:id="#+id/hoopWin1"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:backgroundTint="#2196F3"
android:text="#string/hoopwin1"
android:textSize="24sp"
app:layout_constraintBottom_toTopOf="#+id/cancel"
app:layout_constraintEnd_toStartOf="#+id/guideline"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/score1bk" />
<TextView
android:id="#+id/hoopWin2bk"
android:layout_width="160dp"
android:layout_height="160dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:background="#FFF040"
app:layout_constraintBaseline_toBaselineOf="#+id/hoopWin1bk"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="#+id/guideline" />
<Button
android:id="#+id/hoopWin2"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:backgroundTint="#FF4040"
android:text="#string/hoopwin2"
android:textSize="24sp"
app:layout_constraintBaseline_toBaselineOf="#+id/hoopWin1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="#+id/guideline" />
<Button
android:id="#+id/cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:backgroundTint="#FF00FF"
android:text="#string/cancel"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/hoopWin1bk" />
<androidx.constraintlayout.widget.Guideline
android:id="#+id/guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.5" />
</androidx.constraintlayout.widget.ConstraintLayout>

Navigating effectively in scrollView

In my android application I have a background and at the bottom a horizontal scrollView. In this scrollView I have 4 buttons each one representing a separate activity plus 2 more which are arrows for scrolling left and right, if the user scrolls right then 4 different buttons will populate the scrollview. In my Current VM, it works correctly but if I switch to one with a larger screen then instead of 4 buttons I have 5 or even 5 and a half, at it scrolls much less. My question is how can I always have 6 buttons in my scrollView (4 activity buttons and the extra two arrows for navigating in the scrollView) independently of the size and the density if the screen. This is the xml I've written so far
<?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="#drawable/fonto1" >
<HorizontalScrollView
android:id="#+id/horizontalScrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:fillViewport="true"
android:fitsSystemWindows="true"
android:measureAllChildren="true" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="93dp"
android:background="#000"
android:orientation="horizontal" >
<ImageButton
android:id="#+id/aristerovelos2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/aristerovelos1"
android:layout_marginLeft="25dp"
android:layout_toRightOf="#+id/ellinika"
android:background="#drawable/aristerovelos3"
android:src="#drawable/aristerovelos3" />
<ImageButton
android:id="#+id/ispanika"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/agglika"
android:layout_marginLeft="9dp"
android:layout_toRightOf="#+id/aristerovelos2"
android:background="#drawable/ispanika"
android:src="#drawable/ispanika" />
<ImageButton
android:id="#+id/italika"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/agglika"
android:layout_marginLeft="14dp"
android:layout_toRightOf="#+id/ispanika"
android:background="#drawable/italika"
android:src="#drawable/italika" />
<ImageButton
android:id="#+id/rosika"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/agglika"
android:layout_marginLeft="14dp"
android:layout_toRightOf="#+id/italika"
android:background="#drawable/rosika"
android:src="#drawable/rosika" />
<ImageButton
android:id="#+id/deksivelos2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/aristerovelos1"
android:layout_marginLeft="80dp"
android:layout_toRightOf="#+id/rosika"
android:background="#drawable/deksivelos3"
android:src="#drawable/deksivelos3" />
<ImageButton
android:id="#+id/aristerovelos1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:background="#drawable/aristerovelos3"
android:src="#drawable/aristerovelos3" />
<ImageButton
android:id="#+id/galika"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/agglika"
android:layout_marginLeft="16dp"
android:layout_toRightOf="#+id/agglika"
android:background="#drawable/agglika"
android:src="#drawable/gallika" />
<ImageButton
android:id="#+id/germanika"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/galika"
android:layout_marginLeft="14dp"
android:layout_toRightOf="#+id/galika"
android:background="#drawable/germanika"
android:src="#drawable/germanika" />
<ImageButton
android:id="#+id/ellinika"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/germanika"
android:layout_marginLeft="15dp"
android:layout_toRightOf="#+id/germanika"
android:background="#drawable/ellinika"
android:src="#drawable/ellinika" />
<ImageButton
android:id="#+id/agglika"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="#+id/aristerovelos1"
android:background="#drawable/agglika"
android:src="#drawable/agglika" />
<ImageButton
android:id="#+id/deksivelos1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/aristerovelos2"
android:layout_toRightOf="#+id/ellinika"
android:background="#drawable/deksivelos3"
android:src="#drawable/deksivelos3" />
</RelativeLayout>
</HorizontalScrollView>
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/horizontalScrollView1"
android:layout_alignParentLeft="true"
android:src="#drawable/grammi" />

Android XML adapted for all scree sizes

I am currently developing an android application and am facing a problem.
I am aware that the most common thing to adapt your application to most of the devices is to create different folder named "layout-small", "layout-normal", etc. in order to handle this issue.
However, this does not solve everything : both Samsung S2 and Samsung S3 and considered "normal" screen size, but the given result is very different, even though I also use "dp" to set height and with of most of my views.
How can I adapt my xml for EVERY device PERFECTLY ? I don't mind having the same xml file for every different device, but how do I do that ?
Here is an example of an XML file that renders welle on S3, but is cut down on S2 (the last button appears partially)
<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:useDefaultMargins="false">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Me"
android:id="#+id/textView"
style="#style/title_parameters"
android:layout_alignParentTop="true"
/>
<Button
android:id="#+id/btUpdateProfile"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:text="Update profile"
android:textColor="#drawable/text_color_selected_parameters"
style="#style/button_text"
android:background="#drawable/solo_button_parameters"
android:drawableRight="#drawable/table_view_cell_accessory_disclosure_indicator"
android:layout_below="#+id/textView"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginBottom="10dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Friends"
android:id="#+id/textView2"
style="#style/title_parameters"
android:layout_below="#+id/btUpdateProfile"/>
<Button
android:id="#+id/btFindFriends"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:text="Find friends"
android:textColor="#drawable/text_color_selected_parameters"
style="#style/button_text"
android:background="#drawable/solo_button_parameters"
android:drawableRight="#drawable/table_view_cell_accessory_disclosure_indicator"
android:layout_below="#+id/textView2"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginBottom="10dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Setting"
android:id="#+id/textView3"
style="#style/title_parameters"
android:layout_below="#+id/btFindFriends"/>
<Button
android:id="#+id/btSharing"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:text="Sharing"
android:gravity="top"
android:textColor="#drawable/text_color_selected_parameters"
style="#style/button_text"
android:background="#drawable/top_corner_button_parameters"
android:drawableRight="#drawable/table_view_cell_accessory_disclosure_indicator"
android:layout_below="#+id/textView3"/>
<Button
android:id="#+id/btPushNotification"
android:layout_width="fill_parent"
android:layout_height="50dp"
style="#style/button_text"
android:textColor="#drawable/text_color_selected_parameters"
android:text="Push notification"
android:layout_marginTop="-2dp"
android:background="#drawable/rectangle_button_parameters"
android:drawableRight="#drawable/table_view_cell_accessory_disclosure_indicator"
android:layout_below="#+id/btSharing"/>
<Button
android:id="#+id/btAutomation"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:gravity="bottom"
android:text="Automation"
style="#style/button_text"
android:background="#drawable/bottom_corner_button_parameters"
android:drawableRight="#drawable/table_view_cell_accessory_disclosure_indicator"
android:layout_below="#+id/btPushNotification"
android:textColor="#drawable/text_color_selected_parameters"
android:layout_marginTop="-2dp"/>
<Button
android:id="#+id/btDisconnect"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:text="Disconect"
android:layout_marginTop="20dp"
android:textColor="#drawable/text_color_selected_parameters"
style="#style/button_text"
android:background="#drawable/solo_button_parameters"
android:drawableLeft="#drawable/disconnect"
android:layout_below="#+id/btAutomation"
android:layout_marginBottom="30dp"/>
</RelativeLayout>
I will upload screen shots as soon as I can.
Once again, my question is : how can I have an XML file for every existing device ?
Can you please post some code. It will be better.
Without define fixed size relative layout and use its positional attributes properly. (This is a comment )