any one know how to remove the white vertical thing in the right of datepicker?
i haven't found any solution yet for this background problem.
clik here to link for sreenshot
layout xml file for the activity
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
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">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#drawable/background_detail_destination"
android:padding="10dp"
tools:context="com.example.michael.finalproject.Detail_Destination">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="Choose Date"
android:paddingBottom="10dp"
android:textColor="#android:color/background_light"/>
<DatePicker
android:id="#+id/datepic"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="6dp"
android:calendarTextColor="#android:color/background_light">
</DatePicker>
<Button
android:id="#+id/btnplantravel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/holo_red_light"
android:text="Plan Travel" />
</LinearLayout>
</ScrollView>
java file
private DatePicker datepic;
datepic = findViewById(R.id.datepic);
datepic.setBackground(new ColorDrawable(Color.WHITE));
Related
I want the last viewgroup with ID chats to overlap the previous viewgroups and occupy the whole screen of my phone. With the XML code below I presume it will get what I want. But the codes does not. Please help.
Below is the xml codes.
<?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/root"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.testapp.MainActivity">
<LinearLayout
android:id="#+id/bar"
android:layout_alignParentStart="true"
android:orientation="horizontal"
android:gravity="center_vertical"
android:background="#999999"
android:elevation="10dp"
android:layout_width="match_parent"
android:layout_height="40dp">
<ImageView
android:id="#+id/bar_img"
android:src="#drawable/ic_autorenew_black_24dp"
android:gravity="clip_vertical"
android:paddingStart="8dp"
android:layout_width="36dp"
android:layout_height="36dp" />
<TextView
android:id="#+id/bar_title"
android:text="title"
android:ellipsize="end"
android:layout_weight="1"
android:gravity="center"
android:textColor="#ffffff"
android:textStyle="bold"
android:textSize="18sp"
android:layout_width="0dp"
android:layout_height="wrap_content" />
</LinearLayout>
<FrameLayout
android:id="#+id/root_frag"
android:layout_below="#id/bar"
android:layout_width="match_parent"
android:layout_height="match_parent"></FrameLayout>
<LinearLayout
android:id="#+id/chats"
android:background="#ea2312"
android:orientation="vertical"
android:layout_alignParentStart="true"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/chat_list"
android:orientation="vertical"
android:layout_width`enter code here`="match_parent"
android:layout_height="wrap_content">
<TextView
android:text="hello world"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
this is the preview screenshot.
enter image description here
The "chats" LinearLayout does fill the whole screen, but the "bar" LinearLayout appears on top of it (even though it's defined earlier inside the RelativeLayout) because of its android:elevation attribute.
To make this stop, either remove the elevation attr from the "bar" view, or add a (larger) elevation attr to the "chats" view.
I have a couple of simple UI questions in regards to the initial app screen I am designing:
(a) How can I make the gray box surrounding the 'Join...' and 'Sign...' buttons transparent?
(b) Are there varying degrees of transparency?
(c) When I change between portrait and landscape orientation, my buttons disappear. How can I keep them visible?
Portrait UI...
Landscape UI...
(d) How do I add 'Company XYZ' to the TextView and have it centered above my two buttons inside the gray box?
Below is my current code...
My activity_main.xml code:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
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:fitsSystemWindows="true"
tools:context="com.companyxyz.companyxyz_0002.MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:theme="#style/AppTheme.AppBarOverlay">
</android.support.design.widget.AppBarLayout>
<include layout="#layout/content_main"/>
</android.support.design.widget.CoordinatorLayout>
My content_main.xml code:
<?xml version="1.0" encoding="utf-8"?>
<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:background="#fff"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="48dp"
android:paddingRight="48dp"
android:paddingTop="368dp"
android:paddingBottom="48dp"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:showIn="#layout/activity_main"
tools:context="com.companyxyz.companyxyz_0002.MainActivity">
<LinearLayout
android:background="#eee"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:paddingTop="40dp"
android:paddingBottom="8dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:layout_height="wrap_content"
android:layout_marginRight="2dp"
android:text="Join Free"
android:layout_width="fill_parent"
android:layout_weight="1"/>
<Button
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:text="Sign In"
android:layout_width="fill_parent"
android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>
Problem is with your paddingTop of 368dp which you have given it to the LinearLyaout in content_main. When you rotates to screen from vertical to horizontal this padding push the view out side of the visible region. You need to adjust this padding for the landscape mode with different layout or you can adjust it with the RelativeLayout as suggested in other answers.
A & B: The format for the android:background is hex ARGB, (alpha-red-green-blue), so what you currently have is the same as #FFeeeeee, which is full alpha and grey. Knock that FF (256) down to 00 (0), and it will be fully transparent. So, yes, there are "varying degrees of transparency".
C & D: I've striped all the padding and extra stuff from your content_main.xml, changed to a RelativeLayout and I got this. Let me know if you wanted something different. I also added the login fields to demonstrate the layout anchoring features of RelativeLayout.
Note, you'll need to add stuff back-in like xmlns:tools=... and tools:showIn="#layout/activity_main"
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:background="#fff"
android:layout_width="match_parent"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_height="match_parent">
<!-- Sign in Form -->
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="16dp"
android:layout_alignParentTop="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Username"
android:labelFor="#id/edit_username"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/edit_username"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Password"
android:labelFor="#id/edit_password"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/edit_password"/>
</LinearLayout>
<!-- Button Bar -->
<LinearLayout
android:background="#77eeeeee"
android:layout_width="match_parent"
android:gravity="bottom"
android:orientation="vertical"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<TextView
android:text="Pick an action"
android:layout_gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<LinearLayout android:layout_width="match_parent"
android:id="#+id/registrationButtonRow"
android:layout_height="wrap_content">
<Button
android:layout_height="wrap_content"
android:text="Join Free"
android:id="#+id/btn_register"
android:layout_width="wrap_content"
android:layout_weight="1"/>
<Button
android:layout_height="wrap_content"
android:text="Sign In"
android:id="#+id/btn_sign_in"
android:layout_width="wrap_content"
android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
How do I add the basic gray/black holo background to a TextView and a SeekBar. Both are overlayed over a camera preview contained by the FrameLayout. Currently both are barely visibile because of the missing background.
<?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:orientation="vertical" >
<FrameLayout
android:id="#+id/scanner_camera_preview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TextView
android:id="#+id/scanner_help_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="Den Zoom-Regler benutzen um den Barcode auszuwählen." />
<SeekBar
android:id="#+id/scanner_camera_seek"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#id/scanner_help_text" />
</RelativeLayout>
Modify your XML Layout to this..I have added purple color for text view and red color for seekbar. Change as per your needs
<?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:orientation="vertical" >
<FrameLayout
android:id="#+id/scanner_camera_preview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TextView
android:id="#+id/scanner_help_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#android:color/holo_purple"
android:text="Den Zoom-Regler benutzen um den Barcode auszuwählen." />
<SeekBar
android:id="#+id/scanner_camera_seek"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#id/scanner_help_text"
android:background="#android:color/holo_red_light"/>
</RelativeLayout>
android:background="#drawable/yourdrawable"
I'm trying to use new Layout SlidingPanelLayout and i have a strange behavior when i open the left panel.
This are my rows:
Content row:
I changed row, and picture looks a bit different, but it stills happen.
<?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="?android:attr/listPreferredItemHeight"
android:orientation="vertical" >
<TextView
android:id="#+id/textName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:paddingStart="10dp"
android:textAppearance="?android:attr/textAppearanceListItem"
android:gravity="left|center_vertical"/>
And panel row:
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/text1"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:paddingStart="10dp"
android:textAppearance="?android:attr/textAppearanceListItem"
android:fontFamily="sans-serif-thin"
android:gravity="left|center_vertical"
/>
Sliding activity:
<android.support.v4.widget.SlidingPaneLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/sliding_pane_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:divider="?android:attr/dividerHorizontal"
android:showDividers="middle">
<FrameLayout
android:id="#+id/left_pane"
android:layout_width="280dp"
android:layout_height="match_parent"
android:layout_gravity="start"/>
<FrameLayout
android:id="#+id/content_pane"
android:layout_width="600dp"
android:layout_height="match_parent"/>
I tried to enable or disable hardwareAcceleration, if i enable it, full row is "grey", if i disable it's just views in the row.
Anyone knows what's happening?
SlidingPanelLayout has a property of setSliderFadeColor(int color);
Call the object in your class and set it to Color.TRANSPARENT
I have the following xml file for my android project.
My problem is that the button placed under the list changes its location depanding on the list data.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent" android:weightSum="1">
<EditText android:layout_height="wrap_content" android:layout_width="match_parent" android:id="#+id/EditTextId"/>
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:id="#+id/Id2" android:text="#string/ButtonStr"></Button>
<ListView android:layout_height="wrap_content" android:layout_width="match_parent" android:id="#android:id/android:list"></ListView>
<FrameLayout android:id="#+id/frameLayout1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="0.84"></FrameLayout>
<ImageView android:id="#+id/Id1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="#drawable/button"></ImageView>
</LinearLayout>
I suggest if you dont want your button to shift places add a scrollview around your list
http://developer.android.com/reference/android/widget/ScrollView.html