logo
Tags down

shadow

How to set two different size of text in one button , android api > 24


By : Bionicman
Date : October 14 2020, 02:21 PM
With these it helps How to set two different size of text in one button on Android ? , Try the following:
code :
        Button button = FindViewById<Button>(Resource.Id.myButton);

        SpannableStringBuilder spannable = new SpannableStringBuilder("Big Little");
        spannable.SetSpan(new AbsoluteSizeSpan(50), 0, 3, SpanTypes.ExclusiveInclusive);
        spannable.SetSpan(new AbsoluteSizeSpan(25), 4, 10, SpanTypes.ExclusiveInclusive);

        button.SetText(spannable, TextView.BufferType.Editable);


Share : facebook icon twitter icon

Android : Find best size for Text based on size of Button


By : Spencer Warner
Date : March 29 2020, 07:55 AM
wish helps you If you get the paint for the button with getPaint() you can use measureText() with your text to get the width the text needs for a given setTextSize() setting. You may want to experiment with some spair space.
There is code using to concept for a different case in this question

Android button and the size of text


By : huangjianke
Date : March 29 2020, 07:55 AM
this one helps. The solution is very simple
You should use a dimension.xml with diferent sizes each density/size and place it on:

How to set different text size to one button in android?


By : Ren CW
Date : March 29 2020, 07:55 AM
it helps some times Wrap the two strings in AbsoluteSizeSpan objects

Android Button layout with big text size


By : Regina Ndirangu
Date : March 29 2020, 07:55 AM
seems to work fine I'm trying to make two identical buttons with the same height, but when the text is too long (the second button) then breaks markup. How can I fix it? , Add android:singleLine="true"
code :
<LinearLayout
    android:layout_height="wrap_content"
    android:layout_width="match_parent">

    <Button
        android:singleLine="true"

        android:text="test"
        android:layout_height="100dp"
        android:layout_width="0dp"
        android:layout_weight="1"/>

    <Button
        android:singleLine="true"
        android:padding="0dp"
        android:text="Arterial tension disturbance"
        android:layout_height="100dp"
        android:layout_width="0dp"
        android:layout_weight="1"/>

    </LinearLayout>

Android: equal button size without ellipsizing or truncating button text


By : alaa hassan
Date : March 29 2020, 07:55 AM
Any of those help i adapted the answer from this question to my needs: android custom dialog with scrollview pushes buttons off the screen
the layout is as follows. it does keep the buttons from disappearing into the bottom of the screen when the dialog content is too large, and the button text doesn't truncate anymore, but the buttons are no longer equally sized. if i could get the buttons to draw as wide as the widest button in the button panel, this would be perfect. <-- (please comment if you know how to achieve this):
code :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="10dip">
    <!-- this layout is the message count bar -->


    <!-- this layout is the title bar -->
    <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:layout_weight="0"
            >
        <ImageView
                android:id="@+id/image"
                android:padding="5dip"
                android:visibility="gone"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"/>
        <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="vertical">
            <TextView
                    android:visibility="gone"
                    android:id="@+id/count"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textSize="16sp"
                    style="@style/CustomDialog.TextColor"/>
            <TextView
                    android:id="@+id/title"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:textStyle="bold"
                    style="@style/CustomDialog.TextColor"/>
        </LinearLayout>
    </LinearLayout>

    <!-- this is the body -->
    <ScrollView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:layout_weight="1">
        <TextView
                android:id="@+id/body"
                android:gravity="center"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                style="@style/CustomDialog.TextColor"/>
    </ScrollView>

    <LinearLayout
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:layout_gravity="bottom|center_horizontal"
        android:layout_weight="0">
        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <Button
                android:id="@+id/button1"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:ellipsize="none"
                android:visibility="gone"
                android:gravity="center"
                android:singleLine="true" />

            <Button
                android:id="@+id/button2"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:ellipsize="none"
                android:gravity="center"
                android:singleLine="true" />

            <Button
                android:id="@+id/button3"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:ellipsize="none"
                android:gravity="center"
                android:singleLine="true" />

            <Button
                android:id="@+id/button4"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:ellipsize="none"
                android:gravity="center"
                android:singleLine="true" />
        </LinearLayout>
    </LinearLayout>

    <!-- and this is where the buttons go -->
    <!--<TableLayout-->
            <!--android:layout_gravity="center_horizontal"-->
            <!--android:layout_height="wrap_content"-->
            <!--android:layout_width="wrap_content"-->
            <!--android:stretchColumns="*">-->
        <!--<TableRow>-->
            <!--<Button-->
                    <!--android:id="@+id/button1"-->
                    <!--android:gravity="center"-->
                    <!--android:visibility="gone"-->
                    <!--android:singleLine="true"-->
                    <!--android:layout_weight="1"-->
                    <!--android:layout_width="wrap_content"-->
                    <!--android:layout_height="wrap_content"/>-->
            <!--<Button-->
                    <!--android:id="@+id/button2"-->
                    <!--android:gravity="center"-->
                    <!--android:visibility="gone"-->
                    <!--android:singleLine="true"-->
                    <!--android:layout_weight="1"-->
                    <!--android:layout_width="wrap_content"-->
                    <!--android:layout_height="wrap_content"/>-->
            <!--<Button-->
                    <!--android:id="@+id/button3"-->
                    <!--android:gravity="center"-->
                    <!--android:visibility="gone"-->
                    <!--android:singleLine="true"-->
                    <!--android:layout_weight="1"-->
                    <!--android:layout_width="wrap_content"-->
                    <!--android:layout_height="wrap_content"/>-->
            <!--<Button-->
                    <!--android:id="@+id/button4"-->
                    <!--android:gravity="center"-->
                    <!--android:visibility="gone"-->
                    <!--android:singleLine="true"-->
                    <!--android:layout_weight="1"-->
                    <!--android:layout_width="wrap_content"-->
                    <!--android:layout_height="wrap_content"/>-->
        <!--</TableRow>-->
    <!--</TableLayout>-->
</LinearLayout>
Related Posts Related Posts :
  • How do I get projection of one list to another with Linq?
  • I am using Alpha Vantage API to try and pull daily stock info. I am really new to using APIs and don't know what I am do
  • Get column names and types out of XMLSchema
  • Unable to read large log file with MemoryMappedViewStream
  • looping through file to add to datagridview
  • C# How do I ask for Admin, without "forcing" him
  • System.ComponentModel.Win32Exception: "The system cannot find the file specified"
  • How to add list to SQL query?
  • Visitor pattern: Number arithmetics based on input
  • How to remove a single DataLabel from a Chart made with EPPlus and C#
  • GameObjects will not load after game Restarts
  • Getting all dates between two dates using datepickers and Entity Framework 6
  • What should TResult be when using public async Task to return json response from API HTTP Post
  • Automapper Sub Property Mapping
  • reading a json file exception "Unhandled Exception: System.TypeInitializationException: The type initializer for &q
  • How to get MacOS username in .NET Core console app?
  • How can I extract the first word of every line of a text file in C#
  • HttpClient isn't using Client Certificate for Mutual TLS Auth
  • How do I make a generic dictionary for multiple types implementing the same interface?
  • C# Form add controls on runtime
  • C# - program about while loop
  • Accessing variables in other Windows Form class C#
  • How to display tooltip / context menu from Run object in (wpf) RichTextBox
  • How to get a 0 before a datetime day when the day is below 10 in C#
  • Nothing shows when I tried to fill Combobox with .csv filenames
  • RSA Crypto: Is it require to store keypair after geneating first time
  • potential problems with c# with windows 7 due to .net versions
  • ASP.NET Core 2.1 RedirectToAction appends TempData to url
  • Random Number Generator using C#
  • Mixing MockVerify and FluentAssertions.Should() in C#
  • IdentityServer4 and Web Api in one project fails to authenticate
  • WebApi Core project debug is hanging on await client.GetAsync
  • Why can't I load System.Security.Cryptography.ProtectedData when it's on the same directory as the executable
  • Regular expression repeated sequence of characters
  • How to check all checkbox by pressing one?
  • Is it possible to use Plotly.js in a C# Winforms WebBrowser component?
  • Access to SelectedPath in Form2
  • IlGenerator Emit
  • How to remove initials from name using C#
  • .Net Core 2.2 / Kestrel / Swagger disabling Chunking / Encoding
  • Add comma in string if boolean is false
  • IComparable vs Equals() confused on which one to use
  • Pass object from DB to next page after listbox selection
  • Does Visual Studio 2015 Express for Desktop support JIT debugging?
  • How to properly add HttpRequestHeaders using system.net.http library
  • Calling MySQL Procedure is giving an exception that "procedure cannot be found"
  • Serialize and De-serialize XML with commented sections in C#
  • To update the field in database using Raw SQL?
  • Best way to unit test classes using streams?
  • JSON serialize list of object with listposition C#
  • WPF BIND Dynamically Image by Bitmap Resources
  • How to return a list of model items to an ASP.NET Core SelectListItem?
  • Get enum from specific number
  • Edit a file without changing it existing name
  • Remove from list items that have fields equal to some item fields
  • How to write OrderByDescending and where clause in single LinQ query
  • how to excute entity framework trace sql
  • how to write string array index in ravendb
  • How to update object stored inside an SQLite DB
  • Why does EF Core throws "Database already exists"?
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org