Helly guys.
Im learning xamarin and trying to make a basic food app for android. This app is in RTL direction. Now i have a Listview in my main content which contains a list of custom layouts. Here is a look at this custom layout. I is RTL in Xamarin Designer windows.
And this is the layout axaml code
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layoutDirection="rtl"
android:textDirection="rtl">
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/linearLayout2">
<ImageView
android:src="#drawable/rating4"
android:id="#+id/imgRating"
android:layout_width="70dp"
android:layout_height="20dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="10dp" />
<ImageView
android:src="#drawable/defaultthumbnail"
android:id="#+id/imgThumbnail"
android:layout_width="match_parent"
android:layout_height="70dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp" />
<TextView
android:text="10,000 تومان"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"
android:textStyle="bold"
android:id="#+id/foodPrice"
android:layout_marginLeft="5dp"
android:textDirection="rtl" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginRight="20dp">
<TextView
android:text="نام غذا"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/txtFoodName"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:text="توضیحات غذا"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="12sp"
android:id="#+id/txtFoodDesc" />
<TextView
android:text="تاریخ"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/txtDate"
android:textSize="8sp"
android:textAllCaps="false" />
<TextView
android:text="آشپز"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/txtCook"
android:textSize="8sp"
android:textAllCaps="false" />
</LinearLayout>
And this is my main layout which this listview is in it.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:id="#+id/mainContentLayout"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:showIn="#layout/app_bar_main"
android:layoutDirection="rtl"
android:textDirection="rtl">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/mainContentListView"
android:layoutDirection="rtl"
android:textDirection="rtl" />
</LinearLayout>
But when i run this this is what i get
as you can those 2 linearlayouts inside are following the rule of RTL but are inverted.
I had the same problem and I fixed it by adding the following in the application's manifest:
<manifest>
<application>
android:supportsRtl="true"
</application>
</manifest>
default emulator and preview didn't work well with "RTL" languages. try to test on real android device or try xamarin live player.
also some android devices force "ltr" when the android interface language is English,try to change android language to a "RTL' language.
About android:supportsRtl="true", you can refer to this, it's default value is false.
From your layout axaml code, it displays in VS's Design as:
But it display in AS's Design as:
It is same as the result what you have run.
So, there is something wrong with VS's Design.
If I didn't misread your question, what you want to get is:
So, you need change your layout axaml code to below:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layoutDirection="rtl"
android:textDirection="rtl">
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/linearLayout2">
<ImageView
android:src="#drawable/pause"
android:id="#+id/imgRating"
android:layout_width="70dp"
android:layout_height="20dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="10dp" />
<ImageView
android:src="#drawable/dapao"
android:id="#+id/imgThumbnail"
android:layout_width="match_parent"
android:layout_height="70dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp" />
<TextView
android:text="10,000 تومان"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"
android:textStyle="bold"
android:id="#+id/foodPrice"
android:layout_marginLeft="5dp"
android:textDirection="rtl" />
</LinearLayout>
<View
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="match_parent"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginRight="20dp">
<TextView
android:text="نام غذا"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/txtFoodName"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:text="توضیحات غذا"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="12sp"
android:id="#+id/txtFoodDesc" />
<TextView
android:text="تاریخ"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/txtDate"
android:textSize="8sp"
android:textAllCaps="false" />
<TextView
android:text="آشپز"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/txtCook"
android:textSize="8sp"
android:textAllCaps="false" />
</LinearLayout>
</LinearLayout>
Related
Currently I'm trying to get the custom ring progress bars to display properly on an android sdk level 23 and below. They work perfectly on android SDK 25+.
Im using a custom library for circular progress bars found here: https://github.com/HotBitmapGG/RingProgressBar, above android lolipop, the layout looks like this:
SDK 23+
however on android lolipop the scrollView seen below breaks the rings so that they dont show up:
android SDK <23
If i remove the scroll view below the progress bars they start working again and I have no idea why that is so. Also if I call View.GONE() on one of the relative layouts the Rings show up again. I'm fairly certain this is because the scrollView is not being used as everything fits on the screen.
Here is my XML: (the middle section is pretty repetative)
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
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/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
>
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/swipeRefresh"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:background="#color/Background"
android:theme="#android:style/Theme.Black.NoTitleBar"
android:fillViewport="true">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:background="#color/Background"
>
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#color/colorPrimary"
android:elevation="10dp"
android:minHeight="#dimen/Toolbar_Height"
android:uiOptions="splitActionBarWhenNarrow"/>
<!--Average-->
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".Average"
android:id="#+id/relativeLayoutAverage"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="5"
android:background="#color/Background"
android:paddingBottom="5dp"
android:paddingTop="0dp"
android:paddingEnd="50dp"
android:paddingStart="50dp"
android:layout_marginBottom="10dp"
android:minHeight="#dimen/Average_Row_Height"
>
<TextView
android:id="#+id/AverageText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentTop="true"
android:background="#drawable/circle"
android:fontFamily="#font/roboto_mono"
android:text="#string/Average"
android:textColor="#color/AverageTextColor"
android:textSize="16sp"
android:textStyle="bold"
android:paddingTop="2dp"
/>
<io.netopen.hotbitmapgg.library.view.RingProgressBar
android:id="#+id/AverageBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minHeight="115dp"
android:layout_below="#id/AverageText"
android:layout_marginTop="5dp"
android:elevation="15dp"
app:max="101"
app:ringDiameter="115"
app:ringColor="#android:color/transparent"
app:ringProgressColor="#color/AverageBarColor"
app:ringWidth="12dp"
app:style="STROKE"
app:textColor="#color/TextColor"
app:textIsShow="false"
app:textSize="26sp" />
<TextView
android:id="#+id/AverageInt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/AverageText"
android:layout_centerHorizontal="true"
android:fontFamily="#font/roboto"
android:layout_marginTop="47dp"
android:text=""
android:textColor="#color/TextColor"
android:textSize="20sp"
android:textStyle="bold" />
</RelativeLayout>
<!--Ta buttons-->
<!--Button 1-->
<RelativeLayout
android:id="#+id/relativeLayout"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/button_bg_rectangle_solid"
android:minHeight="#dimen/Row_Height"
android:clickable="true"
android:elevation="3dp"
android:layout_marginTop="0dp"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="4dp"
>
<TextView
android:id="#+id/Period"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:textStyle="normal"
android:fontFamily="#font/roboto_mono"
android:layout_marginTop="3dp"
android:textSize="20sp"
android:text="Period 1:"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:textColor="#color/SecondaryTextColor"
/>
<TextView
android:id="#+id/RoomNumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/Period"
android:textStyle="normal"
android:fontFamily="#font/roboto_mono"
android:layout_marginTop="3dp"
android:textSize="15sp"
android:text=""
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:textColor="#color/TextColor"
/>
<TextView
android:id="#+id/EmptyCourse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/RoomNumber"
android:layout_marginEnd="100dp"
android:gravity="start"
android:layout_marginStart="15dp"
android:layout_centerHorizontal="false"
android:text=""
android:textStyle="bold"
android:textSize="16sp"
/>
<io.netopen.hotbitmapgg.library.view.RingProgressBar
android:id="#+id/SubjectBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_alignParentStart="true"
android:layout_marginStart="10dp"
android:elevation="5dp"
app:max="101"
app:ringColor="#android:color/transparent"
app:ringDiameter="90"
app:ringProgressColor="#color/BarColor1"
app:ringWidth="9dp"
app:style="STROKE"
app:textColor="#color/TextColor"
app:textIsShow="false"
app:textSize="16sp" />
<TextView
android:id="#+id/SubjectInt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignStart="#id/SubjectBar"
android:fontFamily="#font/roboto"
android:layout_marginStart="20dp"
android:text=""
android:textColor="#color/TextColor"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:id="#+id/SubjectAbrv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="false"
android:layout_alignParentEnd="true"
android:layout_marginEnd="30dp"
android:layout_marginTop="25dp"
android:text=""
android:textColor="#color/TextColor"
android:textSize="15sp"
android:fontFamily="#font/roboto"
android:textStyle="bold" />
<TextView
android:id="#+id/SubjectName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/SubjectAbrv"
android:layout_alignStart="#id/SubjectAbrv"
android:layout_marginEnd="5dp"
android:layout_marginTop="5dp"
android:text=""
android:textColor="#color/SecondaryTextColor"
android:textSize="15sp"
android:fontFamily="#font/roboto"
android:textStyle="italic" />
</RelativeLayout>
<!--The same thing repeated another 3 times below......-->
</LinearLayout>
</ScrollView>
</android.support.v4.widget.SwipeRefreshLayout>
<FrameLayout
android:id="#+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="#layout/nav_header_main_drawer"
app:menu="#menu/activity_main_drawer" />
</android.support.v4.widget.DrawerLayout>
If anyone knows why this happens id love to know! Thanks in advance.
Nvm found a workarround. For those that are having the same problem: hardcoding the android:layout_height to a specific dp value should solve the problem.
I am new to android studio and had earlier used layout_alignParentBottom="true" and other alignment commands which worked well.
I was even getting the recommendation comments that android studio gives if it recognises a command.
But Now I created a new project and Android_studio here the code
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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"
tools:context="com.example.shaurya.courtcounter.MainActivity">
<LinearLayout
android:layout_width="368dp"
android:layout_height="495dp"
android:background="#ffdab9"
android:orientation="vertical"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="8dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:gravity="center"
android:text="Team A"
android:textAppearance="?android:textAppearanceLarge" />
<TextView
android:id="#+id/team_a_score"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:gravity="center"
android:text="0"
android:textAppearance="?android:textAppearanceMedium" />
<Button
android:id="#+id/threepoints"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="increment_three"
android:text="3 Points" />
<Button
android:id="#+id/twopoints"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="increment_two"
android:text="2 Points" />
<Button
android:id="#+id/onepoints"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="increment_one"
android:text="Free Throw" />
<Button
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="reset" />
</LinearLayout>
``
At the extreme end of the cde there is a button which I a trying to align but alignment is not working
align attributes you used:
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
dosen't belong to linear layout behaviors, it's belonging to RelativeLayout.
so if you need to reach center for reset button with linearLayout, use
android:layout_gravity="center|anygravityYouWant"
and android:gravity="center".
also you facing some issue with width and height for linearLayout, because you are using ConstraintLayout as parent Layout.
Simply use the Relative Layout as your Parent Layout-
<?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="#ffdab9">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:gravity="center"
android:text="Team A"
android:textAppearance="?android:textAppearanceLarge" />
<TextView
android:id="#+id/team_a_score"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:gravity="center"
android:text="0"
android:textAppearance="?android:textAppearanceMedium" />
<Button
android:id="#+id/threepoints"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="increment_three"
android:text="3 Points" />
<Button
android:id="#+id/twopoints"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="increment_two"
android:text="2 Points" />
<Button
android:id="#+id/onepoints"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="increment_one"
android:text="Free Throw" />
</LinearLayout>
<Button
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="20dp"
android:text="reset" />
</RelativeLayout>
I am facing the issue ,when the soft keyboard is appeared the frame layout in top of the activity is pushed up .The Frame Layout is placed inside the Linear Layout and below the scrollview is placed inside the scrollview multiple edittext are placed . I have tried the answers posted in the stack overflow but still my problem is not solved.
I am buliding the app in target sdk version 25 and mimimum version 16.
I applied `below method to the activity in AndroidManifestFile.
<activity android:name=".Activities.ScamLookUpActivity"
android:configChanges="keyboard|keyboardHidden|screenSize|screenLayout|"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize"/>`
I don't know how to solve this error and tell the reason the why the given method is not appllied to my activity.
This is my xml layout file...
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/activity_scam_look_up"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#eee"
tools:context="com.zcodia.scamlookup.Activities.ScamLookUpActivity">
<FrameLayout
android:id="#+id/frameLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<View
android:layout_width="match_parent"
android:layout_marginTop="20dp"
android:layout_height="?android:attr/actionBarSize"
android:background="#mipmap/bg_splash_cut">
</View>
<View
android:layout_width="match_parent"
android:layout_height="25dp"
android:alpha="1"
android:background="#A82A37" />
<TextView
android:id="#+id/left_buton"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginLeft="12dp"
android:layout_marginTop="30dp"
android:text="#string/menu"
android:textSize="30dp"
android:gravity="center"
android:textColor="#FFF"/>
<com.zcodia.scamlookup.Utils.CustomTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Scam lookup"
android:layout_marginTop="29dp"
android:layout_marginLeft="60dp"
android:textSize="20dp"
android:textColor="#FFF"
android:gravity="center"/>
</FrameLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#f9f9f9"
android:focusableInTouchMode="true"
android:paddingBottom="20dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="10dp"
android:background="#drawable/text_input2"
>
<com.zcodia.scamlookup.Utils.CustomTextView
android:text="Search Scam Database"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:id="#+id/textView4"
android:textSize="20dp"
android:textColor="#000"
android:layout_below="#+id/linearLayout"
android:typeface="sans"
/>
<com.zcodia.scamlookup.Utils.CustomTextView
android:text="Contact Medium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/textView4"
android:layout_marginLeft="10dp"
android:id="#+id/details_id"
android:textColor="#D32F2F"
android:typeface="sans"
android:textSize="15dp"
android:layout_marginTop="10dp"/>
<android.support.v7.widget.RecyclerView
android:layout_width="wrap_content"
android:layout_height="60dp"
android:id="#+id/recyclerView"
></android.support.v7.widget.RecyclerView>
</LinearLayout>
<com.zcodia.scamlookup.Utils.CustomTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Category"
android:id="#+id/textView5"
android:layout_below="#+id/linearLayout2"
android:layout_marginTop="10dp"
android:layout_marginLeft="15dp"
android:textColor="#D32F2F"
android:textSize="15dp"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:orientation="vertical"
android:paddingBottom="20dp"
android:id="#+id/relative_spinner"
android:focusableInTouchMode="true">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:background="#drawable/textinput"
android:layout_marginRight="10dp">
<Spinner
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentTop="true"
android:id="#+id/categorySpinner"
android:text="#string/inheritance"
android:prompt="#string/inheritance"
android:paddingLeft="0dp"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:background="#drawable/textinput"
android:layout_marginRight="10dp">
<Spinner
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="1dp"
android:id="#+id/categorySpinner2"
android:text="#string/inheritance"
android:prompt="#string/inheritance"
android:paddingLeft="0dp"
/>
</RelativeLayout>
<com.zcodia.scamlookup.Utils.CustomEditText
android:inputType="phone"
android:id="#+id/phoneNumber_editText"
android:hint="#string/phonenumber"
android:typeface="sans"
style="#style/CustomFontStyle"
android:layout_marginTop="20dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp">
<AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginLeft="0dp"
android:layout_marginRight="10dp"
android:layout_marginTop="0dp"
android:id="#+id/yourLocation"
android:hint="Location"
android:textColorHint="#757575"
style="#style/CustomFontStyle"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="330dp"
android:text=""
android:id="#+id/scammer_location_font"
android:textColor="#3eb3a0"
android:textSize="25dp"
android:layout_marginTop="10dp"/>
</RelativeLayout>
<com.zcodia.scamlookup.Utils.CustomEditText
android:inputType="textPersonName"
android:hint="#string/scammer_location"
android:id="#+id/scammerLocation_editText"
android:typeface="sans"
style="#style/CustomFontStyle"
android:layout_marginTop="20dp"
/>
<com.zcodia.scamlookup.Utils.CustomEditText
android:inputType="textPersonName"
android:hint="#string/keyWord"
android:id="#+id/keyword_edittext"
android:background="#drawable/textinput"
android:typeface="sans"
style="#style/CustomFontStyle"
android:layout_marginTop="20dp"
/>
</LinearLayout>
<com.wefika.flowlayout.FlowLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/clip_flow_layout"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp">
</com.wefika.flowlayout.FlowLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
>
<com.zcodia.scamlookup.Utils.CustomButton
android:text="Search"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/search_id"
android:background="#mipmap/bg_splash_cut"
android:textColor="#FFFFFF"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"/>
</LinearLayout>
</ScrollView>
The below image is my activity.
when the edittext is pressed the top frame layout is pushed up.
I think you should try "statehidden" and "adjustPan" together.
<activity android:windowSoftInputMode="adjustPan|stateHidden">
Try this answer,
<activity android:windowSoftInputMode="adjustPan"> </activity>
apply this attribute to your Scroll view:android:fitsSystemWindows="true" and Follow this
link
I was trying to create a layout which will "divide" a horizontal line by 3 and fill it with 3 text views. Even though the following is not what I want to achieve the sample is following.
Sample design
So I started to write this and saw some problems.
1)I managed to write the headers next to each other but there are space between them.
2)They dont cover the whole screen
3)The colors and the background shape is different but I can correct it from my activity using ids.
So here is what I tried 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:paddingRight="16dp"
android:paddingLeft="16dp"
>
<TextView
android:id="#+id/sports"
android:text="Sports"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
/>
<TextView
android:id="#+id/science"
android:text="Science"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_toLeftOf="#+id/sports"
/>
<TextView
android:id="#+id/music"
android:text="Music"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/science"
/>
</RelativeLayout>
You need to use weight property.
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="100dp"
android:orientation="horizontal">
<TextView
android:id="#+id/sports"
android:text="Sports"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
<TextView
android:id="#+id/science"
android:text="Science"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
<TextView
android:id="#+id/music"
android:text="Music"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="100dp"
android:orientation="horizontal">
<TextView
android:id="#+id/sports"
android:text="Sports"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
<TextView
android:id="#+id/science"
android:text="Science"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
<TextView
android:id="#+id/music"
android:text="Music"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
</LinearLayout>
</LinearLayout>
I'm using DrawerLayout in my app.
I test it in Samsung note 3 and samsung S4 everything is fine. But when it test to Samsung S3 the layout has messed up.
Please refer to below image
Test in Samsung Note 3 and Samsung S4 :
http://www.imagesup.net/?di=1514046988962
Test in Samsung S3 :
http://www.imagesup.net/?di=14140469921515
My xml layout code as following below :
<include
android:id="#+id/shopping_cart_slider"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="end"
layout="#layout/shopping_cart_redesign"
android:choiceMode="singleChoice" />
And this is layout that included :
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/grey_register_text" >
<LinearLayout
android:id="#+id/shopping_cart_redesign_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/grey_register_text"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<RelativeLayout
android:id="#+id/info_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/white"
android:orientation="vertical" >
<ImageView
android:id="#+id/logo_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:contentDescription="#string/desc_list_item_icon" />
<com.zukami.apps.dev.blynk.util.CustomListView
android:id="#+id/list_shopping_cart"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/logo_image"
android:background="#android:color/white"
android:divider="#color/grey_register_text"
android:dividerHeight="1dp" >
</com.zukami.apps.dev.blynk.util.CustomListView>
<View
android:id="#+id/border"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#+id/list_shopping_cart"
android:layout_marginTop="5dp"
android:background="#color/grey_register_text" />
<RelativeLayout
android:id="#+id/total_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/border"
android:layout_marginTop="10dp" >
<LinearLayout
android:id="#+id/total_text_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="2dp"
android:orientation="vertical" >
<TextView
android:id="#+id/total_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:text="#string/total"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="#+id/merchandise_total"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:text="#string/merchandise_total"
android:textSize="15sp" />
<TextView
android:id="#+id/loyalty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:text="#string/loyalty"
android:textSize="15sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:orientation="vertical" >
<TextView
android:id="#+id/total_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="#+id/total_points"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:textSize="15sp" />
</LinearLayout>
</RelativeLayout>
<View
android:id="#+id/border_two"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#+id/total_layout"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp"
android:background="#android:color/black" />
<Button
android:id="#+id/confirm_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/border_two"
android:layout_marginBottom="2dp"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginTop="10dp"
android:background="#drawable/grey_shopping_cart_button"
android:gravity="center|center_horizontal"
android:text="#string/confirm_order"
android:textColor="#android:color/white"
android:textSize="16sp"
android:textStyle="bold" />
<View
android:id="#+id/space"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_below="#+id/confirm_button"
android:layout_marginTop="5dp" />
</RelativeLayout>
<ImageView
android:id="#+id/receipt_border"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/info_container"
android:layout_marginTop="-6dp"
android:contentDescription="#string/icon"
android:src="#drawable/receipt_border" />
<TextView
android:id="#+id/receipt_footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/receipt_border"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:textColor="#android:color/white"
android:textSize="15sp" />
<ProgressBar
android:id="#+id/progressBar1"
style="?android:attr/progressBarStyleLargeInverse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center"
android:visibility="gone" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
Kindly advise what's wrong with this layout because I have set all width to match parent but still not working in all device.
Really appreciate for any kind help.
Hmm, I cant see anything wrong right now.
One time I had a problem that anything on my code was wrong, but on devices running API 18+ the android:gravity="center_vertical" simple did not work, but I fix it just changing the value of android:target="18" to android:target="16". I choose "16" because it was the version of my Android that was running without any problems.
I don't know if this is your case, but change the android target property at Android Manifest.xml, just give it a try (y)