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
Related
Even in design view it starts somewhere in the middle and I can't scroll up, I can only scroll down. Similiarly when I run the app it shows the content somewhere in the middle and I can only scroll down, seems like the highest point is where I start. I don't know if it's a problem with margins or something else
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<GridLayout
android:id="#+id/GridLayout1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:columnCount="2"
android:rowCount="16"
android:orientation="horizontal"
tools:context=".MainActivity" >
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="#+id/myFrame">
<ImageView
android:id="#+id/my_img1"
android:layout_width="190dp"
android:layout_height="105dp"
android:layout_margin="4dp"
android:src="#drawable/ic_img"/>
<TextView
android:id="#+id/descTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="4dp"
android:layout_marginBottom="34dp"
android:background="#android:color/transparent"
android:text="#string/text_1"
android:textColor="#android:color/black"
android:textSize="16sp"
android:textStyle="bold"/>
</FrameLayout>
.
.
.
Frame layouts repeat 32 times.
Solved by removing android:layout_gravity="center" from GridLayout.
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));
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 two edittext views. One of them has only one line, its the title. But the other one should fill the linearlayout to the end, but it doesn't.
I updated the code so this is my whole xml for this app. I hope someone can find what's wrong. The part that i want to form like this is the part inside the LinearLayout named addView.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/mainLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#ffffff">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<Button
android:id="#+id/addButton"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:background="#drawable/addbuttonstyle"
android:layout_weight="20"/>
<ImageView
android:id="#+id/titleView"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:background="#drawable/titleview"
android:layout_weight="60"/>
<Button
android:id="#+id/orderButton"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:background="#drawable/orderbuttonstyle"
android:layout_weight="20"/>
</LinearLayout>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/addView"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<EditText
android:id="#+id/textBoxTitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="note title"
android:singleLine="true"
/>
<EditText
android:id="#+id/textBoxContent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:hint="content"
/>
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/backgroundLayout"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/background"
/>
</FrameLayout>
I changed textBoxTitle's height to wrap_content and I see this:
Is this what you were hoping for? Also if you want content to appear in the upper-left corner use this attribute:
<EditText
...
android:gravity="top"
/>
So i found what was wrong.
I needed to set layout_height (of the textBoxContent view) to 0dp and layout_weight (of the textBoxContent view) to 1.
The first view should have android:layout_width="wrap_content"
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