This is my layout. My question is that the id is "below_button" LinearLayout is invalid that running on the phone. The phone didn’t display this LinearLayout, but others layout is right. How come?
<?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">
<include
android:id="#+id/title"
layout="#layout/toptitlebar" />
<LinearLayout
android:id="#+id/query_detail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_below="#+id/title"
android:background="#e2dfdf"
android:layout_alignParentLeft="true">
<EditText
android:id="#+id/ram_assistinqnum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_weight="0.45"
android:hint="通知书编号"
android:maxLines="1"
/>
<TextView
android:id="#+id/ram_operate_date"
style="#style/SpinnerCtl_Wrap"
android:gravity="center"
android:layout_margin="10dp"
android:layout_weight="0.45"
android:hint="操作时间"
android:textColor="#color/black"/>
<ImageView
android:id="#+id/ram_query"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="0.1"
android:src="#drawable/ram_query"
android:layout_margin="10dp"/>
</LinearLayout>
<com.sdrcu.operatingdecisions.view.scrollabletbv.ScrollTableView4
android:id="#+id/scrollTableView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/query_detail"
/>
<LinearLayout
android:id="#+id/below_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#e2dfdf"
android:layout_below="#+id/scrollTableView"
>
<ImageView
android:id="#+id/ram_arrow_previous"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="center"
android:layout_weight="0.3"
android:src="#drawable/ram_arrow_previous"/>
<TextView
android:id="#+id/paging"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:gravity="center"
android:text="翻页"
android:textColor="#color/text_blue"
android:textSize="20sp"
/>
<ImageView
android:id="#+id/ram_arrow_next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="center"
android:layout_weight="0.3"
android:src="#drawable/ram_arrow_next"/>
<ImageView
android:id="#+id/ram_agree"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.1"
android:src="#drawable/ram_agree"/>
<ImageView
android:id="#+id/ram_disagree"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.1"
android:src="#drawable/ram_disagree"/>
</LinearLayout>
</RelativeLayout>
#Seal
In my layout editor's Preview I changed the "Theme in Editor" to "Theme"
And I started to get errors like your screenshot.
See:
So, I selected "All" -> "AppTheme" from the "Theme in Editor" option... Do not forget to press "Ok"
And the errors went away:
So, why do not you also try to set it to "All" -> "AppTheme"
Further it appears to me that you might have created style(s) which do not inherit from "proper parent".
Using below example: "AppTheme" inherits all the required attributes from "Theme.AppCompat.Light.DarkActionBar". And thus, you need to only specify the attributes you need modified.
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
...
<item name="colorAccent">#color/colorAccent</item>
...
</style>
replace
android:layout_below="#id/query_detail"
in
<com.sdrcu.operatingdecisions.view.scrollabletbv.ScrollTableView4
android:id="#+id/scrollTableView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/query_detail"
/>
with
android:layout_below="#+id/query_detail"
yes you miss the parameter height and weight
android:layout_width="match_parent"
android:layout_height="wrap_content"
add in your layout it works Use the Tag
Related
My CardView was being shown as expected till android O like this,
But in android P it looks like this, (Transparent white rectangle inside)
This is the style used in all CardView of the app.
<style name="translucentCard" parent="CardView">
<item name="cardCornerRadius">20dp</item>
<item name="cardBackgroundColor">#26ffffff</item>
</style>
If I use non-transparent cardBackgroundColor then the inner rectangle disappears but it's not the solution. I need to use semi-transparent color as used before. Can anyone help me to overcome this please ? Please note, It's only happening in Android Pie.
backward compatible elevation on the latest release
app:cardElevation="0dp"
OR
<item name="cardElevation">0dp</item>
Use This hope this will work :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/rootView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="...">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="..." />
<android.support.v7.widget.CardView
android:layout_width="match_parent"
style="#style/translucentCard"
android:layout_marginTop="#dimen/activity_vertical_margin"
android:layout_height="wrap_content">
<LinearLayout
style="#style/paddedContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/transparent"
android:orientation="vertical">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/login_email">
<EditText
android:id="#+id/.."
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:padding="8dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/login_password">
<EditText
android:id="#+id/editTextPasswordForLogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:padding="8dp" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/activity_vertical_margin"
android:orientation="horizontal">
<TextView
android:id="#+id/textViewForgotPassword"
style="#style/WarrentyLifeTheme.TextAppearance.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="#string/login_forgot_password" />
<Space
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<Button
android:id="#+id/buttonLogin"
android:layout_width="wrap_content"
android:layout_height="#dimen/buttonHeight"
android:paddingLeft="36dp"
android:paddingRight="36dp"
android:text="#string/dashboard_button_login" />
</LinearLayout>
Try setting
android:background="#null"
to LinearLayout inside the CardView or to TextViews inside this LinearLayout.
This way you will remove the background altogether so there won't be any overdraw.
Add this
android:outlineSpotShadowColor="#color/colorGray"
android:outlineAmbientShadowColor="#color/colorGray"
This solved my problem. Use gray color with a low transparency
I have the following layout for my custom log in dialog
<?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:padding="#dimen/padding_large">
<ImageButton android:src="#drawable/ic_settings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/dialog.login.settings"
android:padding="#dimen/margin_medium" />
<TextView android:text="#string/dialog.login.text.user_name"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<EditText android:id="#+id/dialog.login.user_name"
android:layout_width="match_parent"
android:gravity="center"
android:ems="20"
android:layout_height="wrap_content"
android:inputType="text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView android:text="#string/dialog.login.text.password"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<EditText android:id="#+id/dialog.login.password"
android:layout_width="match_parent"
android:gravity="center"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:textAppearance="?android:attr/textAppearanceMedium" />
<CheckBox android:id="#+id/dialog.login.show_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/dialog.login.check.show_password"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_margin="#dimen/margin_medium"
android:checked="false" />
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button android:id="#+id/dialog.login.cancel"
android:drawableStart="#drawable/ic_exit_black"
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_marginEnd="#dimen/margin_medium"
android:text="#string/dialog.login.button.cancel" />
<Button android:id="#+id/dialog.login.connect"
android:text="#string/dialog.login.button.connect"
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_marginStart="#dimen/margin_medium"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
when I create the dialog and setcontentview the width of the dialog becomes equal to that of the image button on the first row
if I remove that , it becomes the size of the EditText (dialog.login.user_name) whose ems is 20
when I make the dialog's constructor call the base dialog constructor with a theme of R.style.Theme.Material.Dialog it does get the correct (about 3/4 of the screen) but the problem is that it ignores my primary and accent colours (which is normal)
Is there a way to have the dialog have the Theme.Material.Dialog size but still keep my own primary/accent colours?
thanks in advance for any help you can provide
After a lot of searching it seems that the solution is to actually replace the dialogTheme attribute of my main theme, so the solution was:
<style name="app.theme"
parent="android:Theme.Material.Light.NoActionBar.Fullscreen">
<item name="android:dialogTheme">#style/app.dialog</item>
......
</style>
<style name="app.dialog"
parent="android:Theme.Material.Light.Dialog">
<item name="android:colorPrimary">#color/primary</item>
<item name="android:colorPrimaryDark">#color/primary.dark</item>
<item name="android:colorAccent">#color/accent</item>
</style>
I have the following xml to display rows in a listView. I want the TextView with the id rowCreatedAt, to wrap around nicely but it never does and only shows 1 line. I tried most of the solutions in the other questions and added them in the code, but it still doesn't work. Can anyone tell me why...?
+I would like to avoid setting the exact size to the textview.
++ To put it differently, why does the rowCreatedAt textView doesn't wrap the text when width/height is set to fill_parent while other textViews wrap texts just fine?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_margin="5dp"
android:layout_marginBottom="5dp" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:id="#+id/rowUserImage"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="#drawable/twitter_icon"
android:layout_margin="5dp"/>
<TextView
android:id="#+id/rowCreatedAt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="10dp"
android:textColor="#ff696969"
android:ellipsize="none"
android:singleLine="false"
android:scrollHorizontally="false"
android:layout_weight="1"
android:maxLines="100"
android:text="aaaaaaaaaaaaaaabbbbbbbbbbbbbb" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/rowUserName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="username"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/rowText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="status text" />
</LinearLayout>
</LinearLayout>
<TextView
android:id="#+id/rowCreatedAt"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="10dp"
android:textColor="#ff696969"
android:ellipsize="none"
android:singleLine="false"
android:scrollHorizontally="false"
android:layout_weight="1"
android:maxLines="100"
android:text="aaaaaaaaaaaaaaabbbbbbbbbbbbbb" />
Change android:layout_width="fill_parent" to android:layout_width="200dp"
Try like this :
<TextView
android:id="#+id/Lesson_Description"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:minLines="4"
android:maxLines="6"
android:gravity="right|center"
android:background="#drawable/filed_shape_corner"
android:inputType="textMultiLine" />
Then do something like in code :
mLessonDescription = (TextView) rootView
.findViewById(R.id.Lesson_Description);
mLessonDescription.setMovementMethod(new ScrollingMovementMethod());
Try out be setting android:ems="10" it will make your edittext that much wide and wraps the other characters.
OR
You should use android:ellipsize="marquee". If you do not want to fix the height.
Add the following style changes to fix the width problem. along with the initial changes
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:singleLine">false</item>
<item name="android:maxLines">100</item>
<item name="android:width">0dp</item>
<item name="android:layout_weight">1</item>
How can I style the blue divider between the title and the content of a Dialog (see screenshot)?
I prefer to do it via xml, but if necessary I'll take a programmatic solution.
I've looked through the default styles.xml and themes.xml of android-15, but I couldn't find anything.
If you are using ActionBarSherlock you can check it out by looking at abs_dialog_title_holo.xml. There you will see that the blue line is a devider that is defined through a view:
<View android:id="#+id/abs__titleDivider"
android:layout_width="fill_parent"
android:layout_height="2dip"
android:background="#color/abs__holo_blue_light" />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:fitsSystemWindows="true">
<TextView android:id="#android:id/title" style="?android:attr/windowTitleStyle"
android:layout_width="match_parent"
android:layout_height="30dp"
android:paddingLeft="16dip"
android:paddingRight="16dip"
android:gravity="center_vertical|left"
android:text="Dialog"
android:textColor="#Color/blue"/>
<View android:id="#+id/titleDivider"
android:layout_width="match_parent"
android:layout_height="2dip"
android:background="#Color/blue" />
<TextView android:id="#android:id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="16dip"
android:paddingRight="16dip"
android:gravity="center_vertical|left"
android:textColor="#android:color/white"
android:text="Your Text"/>
</LinearLayout>
set this xml as content of the class and add below line in manifest file below activity:
android:theme="#android:style/Theme.Black.NoTitleBar.Fullscreen"
I'm in the middle of modifying a test message application and one of the features that I'd like to add to it would be that when a text message is received, a dialog box of some sort would pop up with the text message stuff and the ability to quickly reply to it, all without having to go into the actual application. Taking HandcentSMS as an example, here is what I'm talking about:
Any ideas how to go about doing this, or could anyone point me in a good direction to get started on this?
You can make an activity, and style it with custom style which should inherit Theme.Dialog
Example style:
<style name="Theme.MyDialog" parent="android:style/Theme.Dialog">
<item name="android:windowBackground">#android:drawable/alert_light_frame</item>
<item name="android:textColorPrimary">#android:color/black</item>
<item name="android:textColor">#android:color/black</item>
<item name="android:overScrollMode">never</item>
<item name="android:windowNoTitle">true</item>
</style>
The most important thing is to prepare xml layout of the activity properly.
I suggest to WRAP_CONTENT for everything vertically, and FILL_PARENT horizontally.
Sample layout xml:
<?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="wrap_content"
android:minWidth="280dp"
android:orientation="vertical">
<LinearLayout
android:id="#+id/frg_alert_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#android:id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/topbar_logo"
android:drawablePadding="10dp"
android:gravity="center_vertical"
android:padding="10dp"
android:text="Title"/>
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#android:drawable/divider_horizontal_bright"/>
</LinearLayout>
<FrameLayout
android:id="#+id/customPanel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:visibility="gone">
<FrameLayout
android:id="#+id/custom"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</FrameLayout>
<ScrollView
android:id="#+id/messagePanel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:padding="10dp">
<TextView
android:id="#android:id/message"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Some text"/>
</ScrollView>
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#android:drawable/divider_horizontal_bright"/>
<LinearLayout
android:id="#+id/frg_alert_three_buttons"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="5dp"
android:visibility="gone"
android:weightSum="3">
<Button
android:id="#+id/button_positive"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:layout_weight="1"
android:maxLines="2"
android:minLines="2"
android:text="Button"/>
<Button
android:id="#+id/button_neutral"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:maxLines="2"
android:text="Button"/>
<Button
android:id="#+id/button_negative"
style="?android:attr/buttonStyle"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:maxLines="2"
android:text="Button"/>
</LinearLayout>
<LinearLayout
android:id="#+id/frg_alert_two_buttons"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="#dimen/screenPadding"
android:weightSum="2">
<Button
android:id="#+id/button_positive"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="2"
android:minLines="2"
android:text="Button"/>
<Button
android:id="#+id/button_negative"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:maxLines="2"
android:minLines="2"
android:text="Button"/>
</LinearLayout>
</LinearLayout>
for Create this UI just Create an Activity with background transparent as:
Step 1: add res\values\style.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Smspopuptheme" parent="android:style/Theme.Translucent">
<item name="android:windowNoTitle">true</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:background">#android:color/transparent</item>
</style>
</resources>
Step 2: add theme to in AndroidManifest.xml for activity which u want to show with message as:
<activity
android:label="#string/app_name"
android:theme="#style/Theme.D1NoTitleDim"
android:name=".SmspopuptestActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Step 3: In SmspopuptestActivity.java set FEATURE_NO_TITLE before setContentView as:
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
//Remove notification bar
//this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
Step 4: Your Activity layout look like res/layout/main.xml :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#55000000"
android:gravity="center"
android:orientation="horizontal" >
<LinearLayout
android:id="#+id/frg_alert_buttons"
android:layout_width="fill_parent"
android:layout_height="200dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:background="#android:color/darker_gray"
android:gravity="center"
android:padding="5dp"
android:layout_centerInParent="true"
android:weightSum="3">
</LinearLayout>
</LinearLayout>
add your layout elements in frg_alert_buttons likes Buttons, Textviews,Imageview and EditViews as per your need.
Start SmspopuptestActivity.java Activity when you receive new SMS.
Some helpful resources:
android-listen-for-incoming-sms-messages
SOME SOUCE CODE FOR SMSPOPUP IN ANDROID:
droid-notify
android-smspopup
showsms
smspopup-for-android