I have found a problem with SeekBar. On devices with Android 4,5,6 I do not have such problem, but on Samsung S8 with Android 7 problem with progress line occurs. If I remove rotation parameter, SeekBar becomes horizontal and problem disappears, but I need standard vertical SeekBar.
Update: the same problem on Nexus emulator API 24 (Android 7).
I have attached 2 screen shots from my app running on Android 6 (LG, Sony) and Android 7 (Samsung S8) and code:
<SeekBar android:id="#+id/seekBar"
android:layout_width="100dp"
android:layout_height="42dp"
android:background="#20FFFFFF"
android:rotation="270"
android:layout_gravity="center"
>
</SeekBar>
and full code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="#+id/icon"
android:layout_width="42dp"
android:layout_height="24dp"
android:paddingTop="6dp"
android:background="#20FFFFFF"
android:layout_gravity="center"
android:src="#drawable/iconvolume" />
<LinearLayout
android:layout_width="42dp"
android:layout_height="100dp"
android:gravity="center">
<SeekBar android:id="#+id/seekBar"
android:layout_width="100dp"
android:layout_height="42dp"
android:background="#20FFFFFF"
android:rotation="270"
android:layout_gravity="center"
>
</SeekBar>
</LinearLayout>
</LinearLayout>
i've got this problem, after try many many approach, i was found solution. Just add android:layerType="hardware" or android:layerType="software" will solve your problem
<SeekBar android:id="#+id/seekBar"
android:layout_width="100dp"
android:layout_height="42dp"
android:background="#20FFFFFF"
android:rotation="270"
android:layerType="hardware"
android:layout_gravity="center"
>
</SeekBar>
Related
I have spent 4 hours to resolve this issue but I couldn't solve it Please any help would be appreciated. As I update my android studio this issues stuck in my android studio. I am using android studio latest version 3.2.1.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
tools:context=".View.First_Screen">
<ImageView
android:id="#+id/firstScreen_image"
android:layout_width="match_parent"
android:layout_height="350dp"
android:layout_alignParentTop="true"
android:layout_marginTop="0dp"
android:background="#drawable/snap"
android:src="#drawable/black_transparent" />
<LinearLayout
android:id="#+id/firstScreen_buttonLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/firstScreen_image"
android:layout_marginTop="38dp"
android:orientation="horizontal"
android:weightSum="1">
<Button
android:id="#+id/firstScreen_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="2dp"
android:layout_weight="0.5"
android:background="#drawable/button_background"
android:text="Login" />
<Button
android:id="#+id/firstScreen_register"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_marginRight="5dp"
android:layout_weight="0.5"
android:background="#drawable/button_background"
android:text="register" />
</LinearLayout>
<TextView
android:id="#+id/firstScreen_connectDriver"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/firstScreen_buttonLayout"
android:layout_marginLeft="5dp"
android:layout_marginTop="32dp"
android:text="Or be a captain of uber"
android:textColor="#311B92"
android:textSize="18dp"
android:textStyle="bold" />
</RelativeLayout>
Here is attached image where you can see the difference of layout on both devices
First I would like to confirm which emulator you are using, is it nexus 4 or some other emulator, because in the preview your screen is selected nexus 4 and the view is shown for devices that has the same pixel density and resolution as nexus 4,
Next you have given a fixed height in dp to your ImageView with id - "firstScreen_image". that fixed height i.e. 350dp will behave differently for different devices.
So next question what do you want your screen to look like and how can I help?
I wrote some very simple code with one image and two text views in a Relative Layout.
It all seems fine in the preview but as soon as I try to run the code on my phone, one text view disappears.
I have tried everything, but can't fix the problem (check out the screenshots).
Code in Android Studio Preview
Code on my smartphone
This is my code:
<?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="wrap_content"
>
<ImageView
android:id="#+id/image_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_below="#+id/hb_isabel"
android:contentDescription="TODO"
android:scaleType="centerInside"
android:src="#drawable/androidparty"
/>
<TextView
android:id="#+id/hb_isabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="Happy Birthday,Isabel!"
android:textSize="36sp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="From, Nathalie"
android:textSize="36sp"
/>
</RelativeLayout>
Is there anyone who can help me out?
I am developing an android application that also implements a chat but I am facing a weird issue on a galaxy s3 device running api 18.
s the image clearly show the text aligned on the right isn't well formatted as it should be on a single line. The layout file is as simple as possibile and no issue is shown on other phones and emulators.
Issue Image
Here is my xml layout file:
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textMine"
android:layout_marginBottom="15dp"
android:visibility="visible" >
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:src="#drawable/silh"
android:layout_alignParentRight="true"
android:layout_marginRight="5dp"
android:id="#+id/profilePicMine"
android:layout_alignParentTop="true"
android:focusable="false" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/profilePicMine"
android:layout_toStartOf="#+id/profilePicMine"
android:id="#+id/nuvolaMine">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:visibility="gone"
android:layout_marginRight="10dp"
android:layout_marginLeft="80dp"
android:src="#drawable/home_pic"
android:id="#+id/picMine"/>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/chat_yellow"
android:paddingRight="15dp"
android:layout_marginRight="10dp"
android:id="#+id/textLayoutMine"
android:paddingBottom="10dp"
android:visibility="visible"
android:paddingTop="10dp"
android:paddingLeft="10dp">
<com.sonarmusic.robotoTextViews.RobotoRegularTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textSize="16sp"
android:text="non so"
android:id="#+id/textMessageMine" />
</RelativeLayout>
</RelativeLayout>
<ImageView
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_alignBottom="#id/profilePicMine"
android:layout_alignLeft="#id/profilePicMine"
android:src="#drawable/verde_on"
android:id="#+id/isArtistMine"/>
<RelativeLayout
android:layout_width="5dp"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:background="#color/chat_yellow"
android:layout_alignParentTop="true">
</RelativeLayout>
<com.sonarmusic.robotoTextViews.RobotoLightTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="6sp"
android:textColor="#color/gray_text"
android:text="08-08-2016"
android:id="#+id/timeMine"
android:layout_marginRight="10dp"
android:layout_below="#+id/nuvolaMine"
android:layout_marginTop="5dp"
android:layout_alignLeft="#+id/nuvolaMine" />
</RelativeLayout>
To me it looks like an issue due to right alignment that either android api 18 or both os and device can't render well, another reason why I have this thought is that the texts on the left side(the received ones in green background) are formatted the right way. But I have no clue on how possibily solve it.
PS Not supporting that device is NOT an option
Replace
android:layout_width="wrap_content"
by
android:layout_width="match_parent"
in your RelativeLayouts
I'm facing an issue on nexus 9.
I have a "basic layout" for my view:
<RelativeLayout android:id="#+id/micContainer" android:layout_width="match_parent" android:layout_height="wrap_content"
android:background="#99ffffff" android:layout_alignParentBottom="true" android:layout_marginBottom="15dp" >
<LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_centerInParent="true">
<TextView android:id="#+id/main_ment_0" style="#style/ment_txt" android:text="" android:layout_margin="5dp" />
<TextView android:id="#+id/main_ment_1" style="#style/ment_txt" android:text="" android:layout_margin="10dp" android:layout_marginLeft="10dp" android:visibility="gone" />
<TextView android:id="#+id/main_ment_2" style="#style/ment_txt" android:text="" android:layout_margin="10dp" android:layout_marginLeft="10dp" android:visibility="gone" />
</LinearLayout>
<ImageView android:id="#+id/main_mic" android:layout_width="70dp" android:layout_height="70dp" android:background="#drawable/mic_0" android:layout_margin="3dp" android:layout_centerVertical="true" />
</RelativeLayout>
This works well on a nexus 5:
However on a nexus 9, a grey area is visible and I can't figure why:
Do you have any idea why this grey area is visible (and if yes why it doesn't show on nexus 5) ?
Thank you in advance for your help.
Edit: the background you see behind the relativeLayout is a videoView.
I also tried on other phones (Samsung S*, Pantech Vega) and it's working well.
Here is the complete screenshot of what I have (and what I want) on my nexus 5:
your base RelativeLayout height is wrap_content, change to
android:layout_height="match_parent"
My xml works just fine on the android studios nexus 7 and nexus 10 emulators and the xml looks fine running on my nexus 4. But when I run it on a 7 inch tablet it stretches my image in the y direction only (in landscape activity) and doesn't keep the aspect ratio. I've tried 2 different 7 inch tablets with the same result.I think I've tried changing layoutwidth and layoutheight to just about every possible combination. I also have the same scaling issue if I try it with a imageview instead of an imagebutton. I googled and googled and tried everything but haven't found a solution that works for me. Please help me...
Here is my xml:
<?xml version="1.0" encoding="utf-8"?>
<HorizontalScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/horizontalScrollView"
android:scrollbars="none"
android:fillViewport="true">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal"
android:measureWithLargestChild="false">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/imageButton2"
android:src="#drawable/mainmenu1"
android:background="#android:color/transparent"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:onClick="goToLab101" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/imageButton3"
android:src="#drawable/mainmenu2"
android:background="#android:color/transparent"
android:scaleType="fitXY"
android:adjustViewBounds="true"
android:onClick="goToPeriodicTable" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/imageButton4"
android:src="#drawable/mainmenu3"
android:adjustViewBounds="true"
android:background="#android:color/transparent"
android:scaleType="fitXY"
android:onClick="goToLab102"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/imageButton5"
android:src="#drawable/fountainselector"
android:background="#android:color/transparent"
android:adjustViewBounds="true"
android:scaleType="fitXY"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/imageButton6"
android:src="#drawable/mainmenu5comingsoon"
android:background="#android:color/transparent"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:onClick="goToLab103"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/imageButton7"
android:src="#drawable/mainmenu6"
android:background="#android:color/transparent"
android:adjustViewBounds="true"
android:scaleType="fitXY" />
</LinearLayout>
</HorizontalScrollView>
Add your same image drawables in drawable-large-xhdpi for 7 inch tablet support