语言

Menu
Sites
Language
How to create a Container with "Fit to content" size?

Hello. 

I need to create a custom Popup with Label in it. I've created a layout for Popup in Native Ui Builder, using RelativeLayout for both portrait and landscape orientations. Width of the Popup is different for different orientation. 

Text in Label may be long, so I set the height of Label as "fit to content". As height of Label can become bigger, I supposed to change the height of the whole Popup:

void SetText(const Tizen::Base::String& text) {

    m_myLabel->SetText();

    std::unique_ptr<RelativeLayout> layout(static_cast<RelativeLayout*>(GetLayoutN()));
    layout->Update();

    int newPopupHeight = m_myLabel->GetHeight() /* + other controls height */;

    if (GetHeight() < newPopupHeight) {
        SetSize(GetWidth(), newPoupHeight);
    }
}

This works fine, but only for one orientation. After calling SetSize() the width of Popup will be the same for all orientations.

Is there any simple to make this work for both orientations?

Thanks for any tips. 

 

 

响应

1 回复
Alex Dem

Hi,
I did not find api how to update popup width/height dinamically (I was unable change popup size using SetSize).
Regarding docs looks like you could set size during construct only,
https://developer.tizen.org/dev-guide/2.2.1/org.tizen.native.apireference/classTizen_1_1Ui_1_1Controls_1_1Popup.html
or popup sizes are retrieved from  IDP_POPUP.xml sources

    <Popup id="IDP_POPUP">
        <property accessibilityHint="" color="" titleText="" titleTextColor=""/>
        <layout height="554.0" mode="Portrait" style="" type="LAYOUT_RELATIVE" width="688.0"/>
        <layout height="688.0" mode="Landscape" style="" type="LAYOUT_RELATIVE" width="164.0"/>
    </Popup>

But maybe I did not understand your problem from description.
Alexey.