How to change custom component height programatically
I've prepared custom component based on LinearLayout. Whole component is defined in XML. Currently to use it you have to write:
<com.xxx.android.components.TopMenu
android:layout_width="fill_parent"
android:layout_height="44dp"
/>
Is it possible to set width and height in the java constructor? So it would be possible to write just:
<com.xxx.android.components.TopMenu />
I've tried to modify and set LayoutParams, but it didn't work for me.
Asked by: Aida338 | Posted: 25-01-2022
Answer 1
Not in the constructor, but in the onFinishInflate()
callback to your custom widget, I this might work.
Similar questions
android - How to scroll programatically a ScrollView?
I have a little problem with a ScrollView. I have a layout for an activity which is made with a ScrollView. This scrollview contains two ListViews.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rootViewGroup" android:layout_width="fill_parent"
android:layout_height="wrap_content" ...
How to change string resource xml values in Android programatically?
Is there any possibility to Edit String.xml values in Android? Please suggest me the possible ways. I want to provide Enable/Disable option for my App. To accomplish this I can use SQLite database. But I doesn't like to Use DB for a single variable value. Thanks in Advance. With Regards, Raghavendra K.
Android: (Newb Question) Programatically creating views based on xml
Sorry for the Newb-ness.
I want to create a list of view elements in a LinearLayout (vertical). I created an xml layout that is a TableLayout called "category_list.xml"
<TableLayout>
<TableRow>
<ImageView />
<TextView />
<CheckBox />
</TableRow>
</TableLayout>
I want to iterate an array, on each itera...
registry - Android: Programatically changing phone settings and getting lost calls
Is it possible in Android to programatically change the phone internet settings (proxies also), email settings and other similar? Is there some kind of registry?
and what about getting the lost/received/etc calls? is it possible to get that info?
Programatically send SMS to email using Verizon Motorola Droid on Android
I was wondering if anyone knew the proper way to send an SMS message to an e-mail address using Verizon's CDMA Motorola Droid phone.
The internal messaging application appears to automagically do this. While 3rd party applications like SMSPopup don't seem to be able to properly reply to e-mail addresses unless you compose the message inside the messaging application.
When the internal messaging applicatio...
java - After making a call programatically, my android app crashes
The title explains all... I have this snippet of code in my application:
String url = createTelUrl("3112007315");
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse(url));
context.startActivity(intent);
It does make a call, but once the call ends, my application crashes. I'd like to return to my application once the call has finished, but I read
android - Programatically detect presence of hardware call/hang up keys
One of my clients wants a code method that returns a boolean. True if the Android phone has hardware red/green call/hang up keys and false if it does not.
Sonething like this :
public void keyFeedbackFromInput(KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN
&& (event.getFlags() & KeyEvent.FLAG_VIRTUAL_HARD_KEY) != 0) {
// perform your logic here
}
}
dtmf - How to Programatically Dial a Phone number in the Android SDK?
How do you programatically do this in the Android SDK:
Dial a phone number
Bypass the keypad screen
Send additional DTMF after the number is dialed
Bypass the send DTMF tone prompt
I have managed to do 1 till 3 by dialing +555-1212w1234 but I am wondering if anyone knows how to bypass the send DTMF tone prompt.
android - Creating an ImageView with a certain style programatically
I want to do this programatically:
<ImageView style="@style/TitleBarSeparator" />
Where TitleBarSeparator is:
<style name="TitleBarSeparator">
<item name="android:layout_width">1px</item>
<item name="android:layout_height">fill_parent</item>
<item name="android:background">@color/title_separator</item>...
android - How to connect to internet programatically?
HI,
I'm building an Android application requiring internet connection, and I'm using ConnectivityManager to check whether the device is connected to internet or not. Now, what's the best strategy if it's not connected? Should I quit the application and tell the user to first connect to internet? or is there any way to ask the user if he wants to get connected and connect programatically?
Thanks
Jul
Still can't find your answer? Check out these communities...
Android Google Support | Android Community | Android Community (Facebook) | Dev.io Android