0

I have a view alertpopup.xml which contains in it:

<LinearLayout
    android:id="@+id/navBarTop"
    android:layout_width="match_parent"
    android:layout_height="60dp"
    android:layout_marginTop="5dp"
    android:background="@drawable/alert_nav_bar"
    android:clickable="true"
    android:orientation="horizontal"
    android:padding="0dp" 
    android:visibility="visible">

    <RelativeLayout
        android:id="@+id/navBarBox"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:orientation="vertical" >

        <com.w.view.text.WTextView
            android:id="@+id/navBarDirection"
            android:layout_width="wrap_content"
            android:layout_marginTop="5dp"
            android:layout_marginLeft="5dp"
            android:layout_marginBottom="5dp"
            android:layout_height="match_parent"
            android:layout_centerHorizontal="true"
            android:background="@drawable/big_direction_right"
            android:gravity="center"
            android:textColor="@color/solid_white"
            android:textSize="24sp"
            android:textStyle="bold" />


      </RelativeLayout>
..

this line is executed:

inflater.inflate(R.layout.alert_nav_bar, this);

and later this one:

public NavBar(View view, BottomBar bottomBar) {
    this.view = view;
    this.bottomBar = bottomBar;
    bottomBar.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View paramView) {
            NavBarManager navBarNativeManager = NativeManager.getInstance().getNavBarManager();
            navBarNativeManager.showNavigationResult();
        }
    });
    instImages = instImagesRight;
    topView = view.findViewById(R.id.navBarTop);
    nextView = view.findViewById(R.id.navBarThen);
    boxView = view.findViewById(R.id.navBarBox);

how come all heights are 0 only?

especially topview which has fixed height?

<LinearLayout
    android:id="@+id/navBarTop"
    android:layout_width="match_parent"
    android:layout_height="60dp"

enter image description here

Elad Benda
  • 35,076
  • 87
  • 265
  • 471
  • Has the view been measured yet? Heights are normally 0 initially. See [here](http://stackoverflow.com/questions/4142090/how-do-you-to-retrieve-dimensions-of-a-view-getheight-and-getwidth-always-r). – Geobits Oct 04 '13 at 16:54
  • i added debug print screen while the breakpoint is just after these lines – Elad Benda Oct 04 '13 at 17:02

1 Answers1

0

it looks like you have navBarBox set to wrap content (height) and navBarDirection height to match parent, which means it won't try and calculate how high it should be and just match it's parent which starts at 0 and increases as it's children does, so it stays at 0.

try making navBarDirection wrap content also.

edit: you could also make navBarBox match parent, but I'm not sure what else lives in navBarTop

Eluvatar
  • 2,265
  • 19
  • 24
  • but topview which has fixed height? "60dp" – Elad Benda Oct 04 '13 at 16:48
  • ok... that has nothing to do with `navBarBox ` there can be empty space inside `navBarTop` – Eluvatar Oct 04 '13 at 16:50
  • `topView = view.findViewById(R.id.navBarTop);` and `android:id="@+id/navBarTop" android:layout_width="match_parent" android:layout_height="60dp"` – Elad Benda Oct 04 '13 at 16:54
  • yes I understand that `navBarTop` has a fixed height of 60dp, but it's child `navBarBox` doesn't care because it's just adding up the height of it's children and using that. Then it's child `navBarDirection` is just taking the height of it's parent `navBarBox` and matching that (which is initally 0 because it's set to wrap content) – Eluvatar Oct 04 '13 at 17:01
  • if it's in a dialog has it been shown yet? try just putting it in an activity and see if you have the same issue, it may be due to the dialog not having been drawn yet. – Eluvatar Oct 04 '13 at 17:07
  • no, it means creating the view objects based on the xml, that does not mean those views are visible or have been drawn. – Eluvatar Oct 04 '13 at 17:09
  • but if it's found and created - it has height. Even if it's not visible. no? – Elad Benda Oct 04 '13 at 17:19