I am trying to make a cell that will have two UILabels at the same line.
Like this:
User Name: blablabla
Where User Name is the first UILabel and blablabla is the second UILabel.
I want the first UILabel to be wrap content and the second one to have its content extended until the super view's trailing.
I tried to look for an answer to my question around StackOverflow, but I could not find one. Does someone know how can I achieve that?
I want something just like this:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/first_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="User Name:"/>
<TextView
android:id="#+id/second_label"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="bla bla bla"/>
</LinearLayout>
or like this
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/first_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="User Name:"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<TextView
android:id="#+id/second_label"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="bla bla bla"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="#id/first_label"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
</android.support.constraint.ConstraintLayout>
Try to change content compression resistance priority
Look at these snapshots:
Labels with default content compression resistance priority
I changed content compression resistance priority for label blablabla blablabla, from 750 to 749.
Result is:
you can do this by :
yourLabel.lineBreakMode = NSLineBreakMode.byWordWrapping
You should try the following solution.
For first label.
Add top, left, bottom, width constraint.
Now set number of lines to 0 and Autoshrink to Minimum font size shown as below. You should set your required minimum font size.
For second label
Add top, left, bottom, right.
Now set number of lines to 0 and Autoshrink to Minimum font size shown as below. You should set your required minimum font size.
These changes will make first label's font autoshirnk upto your minimum font size. And will also make the second label to extent the content.
Related
I have a minimal sample project that produces corrupt graphics on a Google Pixel XL and a Xiaomi Mi6, but works correctly on a Samsung Galaxy S6.
Setting android:hardwareAccelerated=false fixes the corrupt graphics but leads to issues with animations and scrolling leaving trails.
The sample project uses MvvmCross, however I have been able to reproduce the behaviour without MvvmCross.
The project code can be found at https://github.com/stevedcc/Xamarin_Broken_Graphics.git
View:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/mainLogo"
android:src="#drawable/company_logo_1"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:adjustViewBounds="true" />
<ImageView
android:id="#+id/main_image"
android:layout_width="wrap_content"
android:layout_height="350dp"
android:layout_below="#drawable/main_image1"
android:adjustViewBounds="true"
android:src="?attr/main_image"/>
<TextView
android:id="#+id/mainScanText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/main_image"
android:gravity="center"
android:textSize="24sp"
android:text="Title" />
</RelativeLayout>
Styles:
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<attr name="company_logo" format="reference" />
<attr name="main_image" format="reference"/>
<attr name="company_color" format="reference" />
<attr name="splash_background" fromat="reference" />
<color name="company_color_1">#7f7f7f</color>
<style name="CompanyTheme"
parent="#android:style/Theme.Material.NoActionBar">
<item name="company_logo">#drawable/company_logo_1</item>
<item name="main_image">#drawable/main_image1</item>
<item name="android:colorBackground">#000000</item>
<item name="company_color">#color/company_color_1</item>
</style>
</resources>
Expected Result as displayed by a Galaxy S6
Actual Result as displayed by a Pixel XL
Can anyone tell me how to fix the Corrupt graphics?
I found the answer myself:
<item name="android:colorBackground">#000000</item>
leads to the issue, if replaced by
<item name="android:colorBackground">#android:color/black</item>
then the project works.
I want to insert a variable number of ImageButtons into a Gridlayout.
(1) My first Idea would be doing this repetition in xml like
<GridLayout>
<RepeatNTimes n="#/class/property">
<ImageButton \>
</RepeatNTimes>
</GridLayout>
But I don't know such a Tag.
(2) The next Idea would be to use a separate xml-File for the ImageButtons. This does not work easily, because they need Grid-Layout-Specific attributes.
<android.support.v7.widget.GridLayout
android:id="#+id/xmlgrid"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
app:columnCount="2">
Necessary parameters for ImageButton.
<ImageButton xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:adjustViewBounds="true"
app:layout_columnWeight="1"
android:background="#android:color/transparent"
android:scaleType="fitXY"
app:srcCompat="#drawable/ic_peg_2" />
(3) Another Idea would be to insert everything programmatically, which is certainly not the most elegant way. But I did not get the Parameters working correctly
ImageButton b = new ImageButton(getContext());
b.setImageResource(Const.BLACK_PEG);
b.setBackgroundColor(Color.TRANSPARENT);
b.setAdjustViewBounds(true);
b.setScaleType(ImageButton.ScaleType.FIT_XY);
// Layout Params
GridLayout.LayoutParams p = new GridLayout.LayoutParams();
p.columnSpec = GridLayout.spec(GridLayout.UNDEFINED, 1, 1f);
b.setLayoutParams(p);
xmlgrid.addView(b);
Wrong position when adding button programmatically
I'm having a problem with label size. I need my graph to show text of node labels with different font sizes.
This is not work:
<node id="155" label="text text" font-size="10000px">
viz:color r="0" g="255" b="0"/>
</node>
And this make another size for node and not for text of label:
<node id="155" label="text text">
<viz:color r="0" g="255" b="0"/>
<viz:size value="17"/>
</node>
Thanks!
There is no way to specify node label font sizes in gexf. This is not covered by the specification. Perhaps the reason is that you can modify this from within Gephi to match your preferences
I want to show the text in uilabel. The text is ,000124520.061112782.,3299985343, I have assign line break mode to character wrap and number of lines to 0. But in label first line is displayed only the , and then other characters are displayed in next line. But i want to display the text in two lines only. But it is displayed in three lines. I don't know why , is displayed in first line. Please anyone help me.
You should set the numberOfLines of your UILabel to 1.
When the numberOfLines property of a UILabel is set to 0 the UILabel will render its text over as many lines as it needs - e.g. its infinite. To fix your text to a single line you should therefore set the property to 1.
Obviously your text may not all fit on a single line so you should also set the UILabel's minimumScaleFactor property to allow the UILabel to adjust its font size downward (to the supplied limit) to fit the content into the frame of the label. You will also need to set the UILabel's adjustsFontSizeToFitWidth property to YES.
Further to the above an easy way to calculate the value for the minimumScaleFactor property is to divide the minimum font size by the maximum font size. So, say for example your label's default font size was 12 and you were happy for it to drop to 10, then assign the minimum scale factor as follows:
myLabel.minimumScaleFactor = 10/12.0f;
I want align text to center on elm_label widget. I can't find any functions about text align as evas object text function or elm_label function. Also, I can't find a function that can get the text size (absolute pixel or relative size) on a label.
I have tried elm_object_style_set with marker, it was showed bold text on center of label, but font size was too small (smaller than default style). (and I don't want bold on text.)
How I can align text to the center of a label?
You can use HTML like markup to customize the way you want to the display the text in elm_label.
To align the text to the center, you can use <align> markup tag with value center .
std::string text = "<align = center> TEXT TO DISPLAY </align>";
Evas_Object *label = elm_label_add(parent);
elm_object_text_set(label,text.c_str());
evas_object_show(label);
You can also use other tags like font_weight, font_style to customize your display text. List of all possible tags can be found here
You can set the alignment of the label through the evas_object API. Likely what you are looking for is:
evas_object_size_hint_align_set(label, 0.5, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
The 0.5 is center, you could try 0.0 for left align and 1.0 for right.