My parent view is a Motion Layout. In it I have a ViewPager which has 2 pages. Each page has a vertical recycler view.
My desired effect is for a textView, which is a child of this motion layout, to change its color on page swipe (and to do it smoothly).
PROBLEM: Nothing happens on swipe. Just a regular ViewPager swipe
Here is my transition:
<Transition
app:constraintSetEnd="#id/end"
app:constraintSetStart="#id/start">
<OnSwipe
app:dragDirection="dragLeft"
app:touchAnchorSide="right"
app:touchAnchorId="#id/news_viewPager"/>
</Transition>
I've set a listener on the Motion Layout motionlayout.addTransitionListener() and I'm debugging in its four methods (such as onTransitionChange()) to see if the animation is set off, but it doesn't even starts.
I've tried adding touchRegionId, disableScroll & disablePostScroll but I'm out of ideas.
Could someone please explain to me why it is not working, and a solution to it (or at least an alternative)? Thank you.
Just in case, here's my full scene xml:
<?xml version="1.0" encoding="utf-8"?>
<MotionScene xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<ConstraintSet android:id="#+id/start">
<Constraint android:id="#id/new_videos_title">
<CustomAttribute
app:attributeName="textColor"
app:customColorValue="#color/navBarOn" />
</Constraint>
<Constraint android:id="#id/news_viewPager" />
<Constraint android:id="#id/new_articles_title">
<CustomAttribute
app:attributeName="textColor"
app:customColorValue="#color/navBarOff" />
</Constraint>
</ConstraintSet>
<ConstraintSet android:id="#+id/end">
<Constraint android:id="#id/news_viewPager" />
<Constraint android:id="#id/new_videos_title">
<CustomAttribute
app:attributeName="textColor"
app:customColorValue="#color/navBarOff" />
</Constraint>
<Constraint android:id="#id/new_articles_title">
<CustomAttribute
app:attributeName="textColor"
app:customColorValue="#color/navBarOn" />
</Constraint>
</ConstraintSet>
<Transition
app:constraintSetEnd="#id/end"
app:constraintSetStart="#id/start">
<OnSwipe
app:dragDirection="dragLeft"
app:touchAnchorSide="right"
app:touchAnchorId="#id/news_viewPager"/>
</Transition>
Related
I like to change the backgroundcolor of a richtexttablecell, I try to solve the problem with lotusscript, but there isn't an method or attribute for this in lotus script.
looks like it is possible to solve this with c api.
can anyone help me?
Use the NotesDXLExporter and NotesDXLImporter:
export the document as DXL,
replace table properties in DXL and
import it back to document.
Make sure that you use notesDXLExporter.RichTextOption=0.
This is an example for a table with background colors in DXL format:
<item name='Body'>
<richtext>
<pardef id='1' />
<par def='1' />
<table widthtype='fixedleft' refwidth='2.1493in'>
<tablecolumn width='1.0667in' />
<tablecolumn width='1.0826in' />
<tablerow>
<tablecell bgcolor='blue'>
<pardef id='3' keepwithnext='true' keeptogether='true' />
<par def='3' />
</tablecell>
<tablecell bgcolor='red'>
<pardef id='4' keepwithnext='true' keeptogether='true' />
<par def='4' />
</tablecell>
</tablerow>
<tablerow>
<tablecell bgcolor='yellow'>
<par def='3' />
</tablecell>
<tablecell>
<par def='4' />
</tablecell>
</tablerow>
</table>
<par def='1' />
</richtext>
</item>
It should be easy to replace the bgcolor properties in DXL.
You can find a code snippet for DXL-export here.
Background color does not appear to be exposed in the LS NotesRichTextStyle or NotesRightTextParagraphStyle classes. The alternate would to use HTML with MIME or the Midas Rich Text LSX from Genii Soft.
I have a ListView with entries that have a lighter background color than the application's layout, and I don't know why.This is a snapshot with red arrows indicating the difference in color: Main_Activity
I have no idea where to start on this.
This is the manifest.xml file that takes up the theme, AppTheme:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.gtfp.workingmemory"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="19"
android:targetSdkVersion="19" />
<!-- Start an Alarm When the Device Boots if past due -->
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme">
<activity
android:name=".appController"
android:launchMode="singleTop"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".editToDoItem"
android:theme="#android:style/Theme.Holo.Dialog" >
</activity>
<receiver android:name=".ToDoAlarm">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<activity
android:name=".AlarmActivity"
android:theme="#android:style/Theme.Holo" >
</activity>
<activity
android:name=".SettingsActivity"
android:theme="#android:style/Theme.Holo" >
</activity>
</application>
</manifest>
That theme in fact is Theme.Holo in the resources file:
<resources>
<!--
Base application theme for API 11+. This theme completely replaces
AppBaseTheme from res/values/styles.xml on API 11+ devices.
-->
<!-- <style name="AppBaseTheme" parent="android:Theme.Holo.Light"> -->
<style name="AppBaseTheme" parent="android:Theme.Holo">
<!-- API 11 theme customizations can go here. -->
</style>
</resources>
This is the main layout for the application you'll see the ListView here:
<RelativeLayout 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"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="${relativePackage}.${activityClass}">
<ListView
android:id="#+id/lvToDos"
android:layout_width="206dp"
android:layout_height="380dp"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true"
android:smoothScrollbar="false"
android:layout_above="#+id/itemEntryView"
android:layout_alignParentTop="true"
>
</ListView>
<LinearLayout
android:id="#+id/itemEntryView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true">
<Button
android:id="#+id/btnNewToDo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="editToDoItem"
android:text="#string/new_item"
android:textSize="#dimen/smallTextSize"/>
</LinearLayout>
</RelativeLayout>
Each row in the ListView is as follows:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:gravity="center"
android:id="#+id/container"
android:layout_height="?android:attr/listPreferredItemHeight"
>
<ImageView
android:id="#+id/priorityImage"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:scaleType="center"
android:focusable="false"
android:clickable="true"
android:layout_marginLeft="5sp"
android:layout_marginRight="5sp"
android:src="#drawable/low"
/>
<TextView
android:id="#+id/itemText"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:focusable="false"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textAlignment="center"
android:textStyle="bold"
/>
<TextView
android:id="#+id/itemDueDate"
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:layout_marginRight="5sp"
android:scaleType="center"
android:textSize="12sp"
android:focusable="false"
android:textStyle="bold"
android:gravity="center"
/>
</LinearLayout>
It seems that you want to change the background color of your list view if this is the case then you can easily do this in your custom listview base adapter you can do it in your base adapter's getview Method.
here is the sample code
public View getView(int position, View convertView, ViewGroup parent)
{
if (convertView == null)
{
convertView = new TextView(ListHighlightTestActivity.this);
convertView.setPadding(10, 10, 10, 10);
//here I am changing the color of text in textview
((TextView)convertView).setTextColor(Color.WHITE);
}
convertView.setBackgroundColor((position == curSelected) ?
Color.argb(0x80, 0x20, 0xa0, 0x40) : Color.argb(0, 0, 0, 0));
((TextView)convertView).setText((String)getItem(position));
return convertView;
}
or alternatively if you know the idea of using selector then you can easily achieve it through selector.
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="false" android:drawable="#color/BackgroundColor" />
<item android:drawable="#color/transparent" />
</selector>
I am sure your problem would get solved in these two above mentioned solutions. Use any of them, which ever is easy for you.
Set app color in list view
<ListView
android:id="#+id/lvToDos"
android:layout_width="206dp"
android:layout_height="380dp"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true"
android:smoothScrollbar="false"
android:background="#color/app_color"
android:layout_above="#+id/itemEntryView"
android:layout_alignParentTop="true"
>
</ListView>
I found the problem.
In the getView, I'm producing 'rounded corners' for every item in the ListView by setting their resource background to a customized drawable:
#Override
public View getView(int position, View convertView, ViewGroup parent) {
:
:
:
:
convertView.setBackgroundResource(R.drawable.rounded_corner);
}
Well, in the drawable, I found there was a solid colour being drawn in there. I commented it out, and now I get what I want:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- <solid android:color="#433E41"/> -->
<corners android:radius="5dp" />
<padding android:left="3dp" android:top="3dp" android:right="3dp" android:bottom="3dp" />
<stroke android:width="3dp" android:color="#E6E6E6"/>
</shape>`enter code here`
I just happened upon this while investigating another matter (I hate porgramming). Appreciate your efforts regardless.
I have the following selector for a button (with 2 states, regular and pressed):
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" >
<shape>
<solid
android:color="#3498DB" />
<stroke
android:width="1dp"
android:color="#2980B9" />
<corners
android:radius="0dp" />
<padding
android:left="12dp"
android:top="12dp"
android:right="12dp"
android:bottom="12dp" />
</shape>
</item>
<item>
<shape>
<solid
android:color="#2980B9" />
<stroke
android:width="1dp"
android:color="#2980B9" />
<corners
android:radius="0dp" />
<padding
android:left="12dp"
android:top="12dp"
android:right="12dp"
android:bottom="12dp" />
</shape>
</item>
</selector>
My button has the following which specifies the background as the above selector:
<Button
android:id="#+id/button_LaunchShiftsGame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/ShiftsMode"
android:background="#drawable/selector_Button"
style="#style/Button_Text" />
I need to access and change the colors for both states from code when the Activity loads.
How can I do this?
StateListDrawable gradientDrawable = (StateListDrawable) inflatedView.getBackground();
DrawableContainerState drawableContainerState = (DrawableContainerState) gradientDrawable.getConstantState();
Drawable[] children = drawableContainerState.getChildren();
LayerDrawable selectedItem = (LayerDrawable) children[0];
LayerDrawable unselectedItem = (LayerDrawable) children[1];
GradientDrawable selectedDrawable = (GradientDrawable) selectedItem.getDrawable(0);
GradientDrawable unselectedDrawable = (GradientDrawable) unselectedItem.getDrawable(0);
selectedDrawable.setStroke(STORKE_SIZE, NOTIFICATION_COLOR);
unselectedDrawable.setStroke(STORKE_SIZE, NOTIFICATION_COLOR);
I used this to change the stroke, it can be helpfull.
This is the Kotlin version of the #Borja's answer with drawable resource
val drawableRes: Drawable? = ResourcesCompat.getDrawable(mContext.resources, R.drawable.drawable_res_id, null)
val drawableContainerState: DrawableContainer.DrawableContainerState = drawableRes?.constantState as DrawableContainer.DrawableContainerState
val children: Array<Drawable> = drawableContainerState.children
val selectedItem: GradientDrawable = children[0] as GradientDrawable
val unselectedItem: GradientDrawable = children[1] as GradientDrawable
selectedItem.setStroke(2, colorState)
unselectedItem.setStroke(2, colorState)
and yes! Many thanks to #Borja. I found this working well as in 2022.
I have below selector round_circle_blue.xml shape xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="oval">
<size android:width="#dimen/_50sdp" android:height="#dimen/_50sdp" />
<solid android:color="#color/color_blue" />
<stroke android:width="#dimen/_2sdp" android:color="#color/white" />
</shape>
</item>
</selector>
And I have set it as background in text view as below
<TextView
android:id="#+id/tvActivityicon"
android:layout_width="#dimen/_40sdp"
android:layout_height="#dimen/_40sdp"
android:textColor="#color/white"
android:gravity="center"
android:text="A"
android:textSize="#dimen/_14sdp"
android:background="#drawable/round_circle_blue" />
and in kotlin file i have use below code to change the color.
val gradientDrawable = tvActivityicon.background as StateListDrawable
val drawableContainerState = gradientDrawable.constantState as DrawableContainer.DrawableContainerState
val children = drawableContainerState!!.children
val selectedItem = children[0] as GradientDrawable
selectedItem.setColor(Color.parseColor("#FD00DF"))
In the JavaFX Scene Builder, is it somehow possible to view the FXML code for the current layout without saving to a file and view the saved file?
right click on the root node in scene builder and then choose copy . and paste it in any text editor.
out put :
<Group id="sb-clipboard" xmlns:fx="http://javafx.com/fxml">
<fx:define>
<AnchorPane id="AnchorPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0">
<children>
<Button id="button1" layoutX="140.0" layoutY="104.0" mnemonicParsing="false" text="Button" />
<RadioButton id="radioButton1" layoutX="283.0" layoutY="172.0" mnemonicParsing="false" text="RadioButton" />
<ToggleButton id="toggleButton1" layoutX="94.0" layoutY="234.0" mnemonicParsing="false" text="ToggleButton" />
</children>
</AnchorPane>
</fx:define>
</Group>
I have created a custom button like this :
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="false" android:state_pressed="false">
<shape>
<gradient
android:endColor="#color/title_dark_red"
android:startColor="#color/title_red"
android:angle="270" />
<stroke
android:width="1dp"
android:color="#color/red_stroke" />
<corners
android:radius="3dp" />
<padding
android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp" />
</shape>
</item>
<item android:state_focused="true" android:state_pressed="true">
<shape>
<gradient
android:endColor="#color/title_pressed_red"
android:startColor="#color/title_pressed_red"
android:angle="270" />
<stroke
android:width="1dp"
android:color="#color/red_stroke" />
<corners
android:radius="3dp" />
<padding
android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp" />
</shape>
</item>
<item android:state_focused="false" android:state_pressed="true">
<shape>
<gradient
android:endColor="#color/title_pressed_red"
android:startColor="#color/title_pressed_red"
android:angle="270" />
<stroke
android:width="1dp"
android:color="#color/red_stroke" />
<corners
android:radius="3dp" />
<padding
android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp" />
</shape>
</item>
</selector>
The problem is sensitivity of the button is very bad, not like the regular buttons. The buttons are not too small in the screen, so it's easy to touch.
What can be the problem ?
P.S I'm using Button.OnClickListener() to set click handler.
Button is in relative layout structure :
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="vertical"
>
<TextView
android:id="#+id/titlePlace"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:background="#drawable/expand_bg"
android:gravity="center_vertical"
android:text=""
android:textColor="#color/titletextcolor"
android:textSize="18sp"
android:textStyle="bold" />
<Button
android:id="#+id/backButton"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_alignBaseline="#+id/showButton"
android:layout_alignBottom="#+id/showButton"
android:layout_alignParentLeft="true"
android:background="#drawable/custom_button_back"
android:layout_marginLeft="5dip"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:text="Places"
android:textColor="#color/white"
android:textSize="12sp"
android:textStyle="bold" />
</RelativeLayout>
It's a hardware related question. Software just takes on click event sent by hardware and checks whether it's in view's bounds.
Other potential issues:
inaccurate touch screen
view was animated and moved to different position
view is too small or finger too big ;)