EzDevInfo.com

layout interview questions

Top layout frequently asked interview questions

What is clearfix?

Recently I was looking through some website's code, and saw that every <div> had a class clearfix.

After a quick Google search, I learned that it is for IE6 sometimes, but what actually is clearfix? Could you provide some examples of a layout with clearfix, compared to a layout without clearfix?


Source: (StackOverflow)

Android Drawing Separator/Divider Line in Layout?

I would like to draw a line right in the middle of a layout and use it as a separator of other items like TextView. Is there a good widget for this. I don't really want to use an image as it would be hard to match the other components to it. And I want it to be relatively positioned as well. Thanks


Source: (StackOverflow)

Advertisements

Get the size of the screen, current web page and browser window

How can I get windowWidth, windowHeight, pageWidth, pageHeight, screenWidth, screenHeight, pageX, pageY, screenX, screenY which will work in all major browsers?

screenshot describing which values are wanted


Source: (StackOverflow)

CSS - Expand child DIV height to parent's height

I have the page structure as:

<div class="parent">
    <div class="child-left floatLeft">
    </div>

    <div class="child-right floatLeft">
    </div>
</div>

Now, the child-left DIV will have more content, so the parent DIV's height increases as per the child DIV.

But the problem is child-right height is not increasing. How can I make its height as equal to it's parent?


Source: (StackOverflow)

How to make an ImageView with rounded corners

In Android, an ImageView is a rectangle by default. How can I make it a rounded rectangle (clip off all 4 corners of my Bitmap to be rounded rectangles) in the ImageView?


Source: (StackOverflow)

Algorithm to implement a word cloud like Wordle

Context

My Questions

  • Is there an algorithm available that does what Worlde does?
  • If no, what are some alternatives that produces similar kinds of output

Why I'm asking

  • just curious
  • want to learn

Source: (StackOverflow)

How to make android app's background image repeat

I have set a background image in my app, but the background image is small and I want it to be repeated and fill in the whole screen. What should I do?

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/bg"
    android:tileMode="repeat">

Source: (StackOverflow)

Get screen dimensions in pixels

I created some custom elements, and I want to programmatically place them to the upper right corner (n pixels from the top edge and m pixels from the right edge). Therefore I need to get the screen width and screen height and then set position:

int px = screenWidth - m;
int py = screenHeight - n;

How do I get screenWidth and screenHeight in the main Activity?


Source: (StackOverflow)

How to make layout with rounded corners..?

Please anyone can help me . How to make layout with rounded corners.. i want to apply rounded corners to my LinearLayout.


Source: (StackOverflow)

Set the layout weight of a TextView programmatically

I'm trying to dynamically create TableRow objects and add them to a TableLayout. The TableRow objects has 2 items, a TextView and a CheckBox. The TextView items need to have their layout weight set to 1 to push the CheckBox items to the far right.

I can't find documentation on how to programmatically set the layout weight of a TextView item.


Source: (StackOverflow)

Are fluid websites worth making anymore? [closed]

I'm making a website now and I am trying to decide if I should make it fluid or not. Fixed width websites are much easier to make and also much easier to make them appear consistent.

To be honest though, I personally prefer looking at fluid websites that stretch to the full width of my monitor. My question comes from the fact that in most modern browsers you can hold control and scroll your mouse wheel to basically resize any website.

So is creating a fluid website worth the trouble?


Source: (StackOverflow)

How to set Bullet colors in UL/LI html lists via CSS without using any images or span tags [duplicate]

This question already has an answer here:

Imagine a simple unsorted list, with some <li> items nested inside <ul> tags. Now, I have defined the bullets to be square shaped via list-style:square; however, if I set the color of the <li> items, color: #F00; then everything becomes red!

While I ONLY want to set the color of these square bullets. Is there an elegant wat to define only the color of the bullets in CSS without using ANY sprite images nor any cumbersome span tags?

HTML

<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
<ul>

CSS

li{
   list-style:square;
}

Source: (StackOverflow)

How do you keep parents of floated elements from collapsing? [duplicate]

This question already has an answer here:

Although elements like <div>s normally grow to fit their contents, using the float property can cause a startling problem for CSS newbies: if floated elements have non-floated parent elements, the parent will collapse.

For example:

<div>
    <div style="float: left;">Div 1</div>
    <div style="float: left;">Div 2</div>
</div>

The parent div in this example will not expand to contain its floated children - it will appear to have height: 0.

How do you solve this problem?

I would like to create an exhaustive list of solutions here. If you're aware of cross-browser compatibility issues, please point them out.

Solution 1

Float the parent.

<div style="float: left;">
    <div style="float: left;">Div 1</div>
    <div style="float: left;">Div 2</div>
</div>

Pros: Semantic code.
Cons: You may not always want the parent floated. Even if you do, do you float the parents' parent, and so on? Must you float every ancestor element?

Solution 2

Give the parent an explicit height.

<div style="height: 300px;">
    <div style="float: left;">Div 1</div>
    <div style="float: left;">Div 2</div>        
</div>

Pros: Semantic code.
Cons: Not flexible - if the content changes or the browser is resized, the layout will break.

Solution 3

Append a "spacer" element inside the parent element, like this:

<div>
    <div style="float: left;">Div 1</div>
    <div style="float: left;">Div 2</div>
    <div class="spacer" style="clear: both;"></div>
</div>

Pros: Straightforward to code.
Cons: Not semantic; the spacer div exists only as a layout hack.

Solution 4

Set parent to overflow: auto.

<div style="overflow: auto;">
    <div style="float: left;">Div 1</div>
    <div style="float: left;">Div 2</div>        
</div>

Pros: Doesn't require extra div.
Cons: Seems like a hack - that's not the overflow property's stated purpose.

Comments? Other suggestions?


Source: (StackOverflow)

How do I specify different Layouts in the ASP.NET MVC 3 razor ViewStart file?

I would like to have 2 separate Layouts in my application. Let say one is for the Public section of the website and the other is for the Member side.

For simplicity lets say all the logic for each of theses sites is wrapped neatly into 2 distinct controllers.

  • PublicController
  • StaffController

And that they each have a corresponding Layout for all the View under each.

  • _PublicLayout.cshtml
  • _StaffLayout.cshtml

How do I use the _ViewStart.cshtml file to specify that all View's / Action under "Public" use the PublicLayout and everything under "Staff" use the StaffLayout?

Thanks!


Source: (StackOverflow)

How to get controls in WPF to fill available space?

Some WPF controls (like the Button) seem to happily consume all the availible space in its' container if you don't specify the height it is to have.

And some, like the ones I need to use right now, the (multiline) TextBox and the ListBox seem more worried about just taking the space necessary to fit their contents, and no more.

If you put these guys in a cell in a UniformGrid, they will expand to fit the available space. However, UniformGrid instances are not right for all situations. What if you have a grid with some rows set to a * height to divide the height between itself and other * rows? What if you have a StackPanel and you have a label, a list and a button, how can you get the list to take up all the space not eaten by the label and the button?

I would think this would really be a basic layout requirement, but I can't figure out how to get them to fill the space that they could (putting them in a DockPanel and setting it to fill also doesn't work, it seems, since the DockPanel only takes up the space needed by its' subcontrols).

A resizable GUI would be quite horrible if you had to play with Height, Width, MinHeight, MinWidth etc.

Can you bind your Height and Width properties to the grid cell you occupy? Or is there another way to do this?


Source: (StackOverflow)