I have a Spinner I'm trying to give a transparent background. Then on Load it can have a white background. However, no matter what background I give it's always white! Any help is appreciated.
<Spinner
android:id="#+id/fertilizer1_amount_unit"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
android:background="#00FF0000"
local:MvxDropDownItemTemplate="#layout/spinneritemdropdown"
local:MvxBind="SelectedItem ChemigationItem.Fertilizers[0].Unit;Enabled ChemigationItem.IsNew" />
SpinnerItemDropDown XAML:
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
style="?android:attr/spinnerDropDownItemStyle"
android:singleLine="true"
android:background="#color/white"
android:textColor="#color/text_gray"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeightSmall"
android:ellipsize="marquee"
local:MvxBind="Text Caption" />
This is what it looks like:
Thanks,
The reason for that is your CheckedTextView's background property:
android:background="#color/white"
Should actually be something like this:
android:background="#android:color/transparent"
Related
all the pages my app is navigation page . I wanted to know how to put an icon on all pages and in the navigation bar section ?
I want to write the code once and apply it to all pages.
Because when I enter the nested pages, icon disappears!
Thanks in advance to those who help me!
You could add an icon to the toolbar in the Android app project.
The default layout for the toolbar in a new template Forms app is:
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:popupTheme="#style/ThemeOverlay.AppCompat.Light" >
</android.support.v7.widget.Toolbar>
Add an icon to this:
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:popupTheme="#style/ThemeOverlay.AppCompat.Light" >
<ImageView
android:src="#drawable/star_small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</android.support.v7.widget.Toolbar>
Updated:
Set id for the imageview in Toolbar.
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:popupTheme="#style/ThemeOverlay.AppCompat.Light" >
<ImageView
android:id="#+id/imageView1"
android:src="#drawable/star_small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</android.support.v7.widget.Toolbar>
Add the code in MainActivity after LoadApplication(new App());.
var imageview = FindViewById<ImageView>(Resource.Id.imageView1);
imageview.Click += delegate
{
Console.WriteLine("start clicked!");
};
How can I enter HorizontalOptions="End" in the Toolbaritem.xml? I want to go to the right side of the page!
Add the code below in ImageView.
android:layout_gravity="end"
Screenshot:
Just use in your page:
<ContentPage
NavigationPage.HasNavigationBar="True"
NavigationPage.HasBackButton="False">
<NavigationPage.TitleView>
<Image />
</NavigationPage.TitleView>
YOUR VIEW
</ContentPage>
I have tried to use FAB button for add new somethings in my android application, but FAB have not showed its source icon. can you help me how i resolve it?
this is my main_activity.xml:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="6"
android:id="#+id/main_container">
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/frg_holder"/>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:elevation="6dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:src="#drawable/ic_add"/>
</RelativeLayout>
and this is a ic_add.xml create icon inside of fAB:
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/>
</vector>
and this is gradle :
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
implementation 'com.google.android.material:material:1.3.0-alpha03'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'com.github.samanzamani.persiandate:PersianDate:0.8'
implementation 'com.android.support:support-v4:29.1.0'
implementation 'com.android.support:design:29.0.0'
}
I want to implement bounce animation effect on android recycleview.
how can I do that?
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_view"
android:scrollbars="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
Replace RecyclerView with RecyclerViewBouncy.
Add dependency:
dependencies {
implementation 'com.chauthai.overscroll:overscroll-bouncy:0.1.0'
}
In layout:
<com.chauthai.overscroll.RecyclerViewBouncy .../>
You can only use LinearLayoutManager
I am showing a fab button on bottom of CoordinatorLayout. On top of that FAB, I want to show a dialog(animating it from bottom) and animate FAB to top of same dialog and make it work like close button for the dialog.
I know if we use CoordinatorLayout with FAB, SnackBar behave with same kind of animation but I want the same animation for dialog enter and exit too.
Is there any way I can achieve the same animation?
To show your snackbar
public static void showSnackBar(#NonNull View view, #NonNull CharSequence text,
#Snackbar.Duration int duration) {
Snackbar snack = Snackbar.make(view, text, duration);
TextView snackTextView = (TextView) snack.getView().findViewById(android.support.design.R.id.snackbar_text);
snackTextView.setMaxLines(5);
snack.show();
}
Here view is your reference to coordinator layout
In your xml place your fab button like this
<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:id="#+id/coordinatorLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/stream_refresh_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<android.support.v7.widget.RecyclerView
android:id="#+id/stream_recyclerview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="false"
android:scrollbars="vertical" />
</android.support.v4.widget.SwipeRefreshLayout>
<ProgressBar
android:id="#+id/groupLoadingView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
<android.support.design.widget.FloatingActionButton
android:id="#+id/postButton"
android:layout_width="58dp"
android:layout_height="58dp"
android:layout_marginBottom="16dp"
android:layout_marginRight="16dp"
android:scaleType="center"
android:src="#drawable/chat_newpost_button_selector"
app:backgroundTint="#color/light_blue_color"
app:borderWidth="0dp"
app:elevation="6dp"
app:layout_anchor="#+id/stream_recyclerview"
app:layout_anchorGravity="bottom|right|end" />
</android.support.design.widget.CoordinatorLayout>
I am making many view objects in xml.
<ImageView id="Keyboard0" />
<ImageView id="Keyboard1" />
<ImageView id="Keyboard2" />
<ImageView id="Keyboard3" />
<ImageView id="Keyboard4" />
<ImageView id="Keyboard5" />
I would like to make these id's as array.
For example, I would like to access each objects like this
$.Keyboard[0].image = 'img/test.png';
Is it possible?
You can access your ids using this kind of for loop:
for (var i = 0; i <= 5; i++) {
$['Keyboard' + i].image = 'img/test.png';
}