Note that there are some explanatory texts on larger screens.

plurals
  1. POWhen a view's layout_width is wrap_content, it won't display
    primarykey
    data
    text
    <p>When i add a TextView which layout_with is wrap_content to a linearlayout, the TextView won't display because the measured width is 0. But i give the text a fixed with, i display properly.</p> <p>this is the code will display a red block on the screen</p> <pre><code> private void setupDialerTab() { Intent intent = new Intent("com.android.phone.action.TOUCH_DIALER"); intent.setClass(this, TwelveKeyDialer.class); StickyTabs.setTab(intent, TAB_INDEX_DIALER); View view = new View(this); view.setBackgroundColor(Color.RED); view.setLayoutParams(new LayoutParams(80, 80)); mTabHost.addTab(mTabHost.newTabSpec("dialer") .setIndicator(view) .setContent(intent)); /* mTabHost.addTab(mTabHost.newTabSpec("dialer") .setIndicator(getString(R.string.dialerIconLabel), getResources().getDrawable(R.drawable.ic_tab_dialer)) .setContent(intent)); */ } </code></pre> <p>This is the code nothing will display.</p> <pre><code> private void setupContactsTab() { Intent intent = new Intent(UI.LIST_DEFAULT); intent.setClass(this, ContactsListActivity.class); StickyTabs.setTab(intent, TAB_INDEX_CONTACTS); TextView tv = new TextView(this); tv.setText("hb2"); mTabHost.addTab(mTabHost.newTabSpec("contacts") .setIndicator(tv) .setContent(intent)); /* mTabHost.addTab(mTabHost.newTabSpec("contacts") .setIndicator(getText(R.string.contactsIconLabel), getResources().getDrawable(R.drawable.ic_tab_contacts)) .setContent(intent)); */ } </code></pre> <p>I have found the solution myself. I have thought the default layoutparam of textView is wrap_content. But in fact, when i debug with hierarchy view, it turn out to be matchparent and 0. So if add <code>tv.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));</code>, everything work out good.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload