logo
down
shadow

Centre Buttons horizontally and vertically


Centre Buttons horizontally and vertically

By : user3099721
Date : January 11 2021, 03:34 PM
this will help To align item in center with position: 'absolute' you have to add following style
code :
 {
    position: "absolute",
    top: 0,
    left: 0,
    right: 0,
    bottom: 0,
    justifyContent: "center",
    alignItems: "center"
  }
{ flex: 1 }
import React from "react";
import { View, Text, StyleSheet } from "react-native";

export default class Home1 extends React.Component {
  render() {
    return (
      <View style={styles.mainContainer}>
        <Text style={styles.score}>Score: 50</Text>
        <View style={styles.container}>
          <Text>Animator container</Text>
        </View>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  mainContainer: { flex: 1 },
  container: {
    position: "absolute",
    top: 0,
    left: 0,
    right: 0,
    bottom: 0,
    justifyContent: "center",
    alignItems: "center"
  },
  score: {
    fontSize: 30,
    alignItems: "center",
    top: 100
  }
});



Share : facebook icon twitter icon
Centre buttons horizontally & vertically

Centre buttons horizontally & vertically


By : Stefano
Date : March 29 2020, 07:55 AM
help you fix your problem To center the buttons horizontally, #menuBar width should be 446px not 450px.
To center the buttons vertically, .button height should be 190px and #menuBar height should be 395px.
android - centre vertically and horizontally text with 2 buttons side-by-side beneath

android - centre vertically and horizontally text with 2 buttons side-by-side beneath


By : Trev
Date : March 29 2020, 07:55 AM
around this issue I have a view. I want an image logo to appear in the top left of the layout and in the centre of the layout (both horizontally and vertically) I want text with 2 buttons (side-by-side) below the text. Here is what I have and it does not work...any help? , I think this does what you want:
code :
<ImageView
    android:id="@+id/imgLogo"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_x="-6px"
    android:layout_y="32px"
    android:background="@drawable/logo" />

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="0dp"
    android:layout_centerVertical="true"
    android:gravity="center_vertical"
    android:layout_weight="1"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/txt1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Welcome to my app. Please select your language"
        android:textColor="#FFFFFF"
        android:textSize="20sp" />

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/TextView01"
        android:layout_centerInParent="true"
        android:background="@android:drawable/bottom_bar"
        android:gravity="center"
        android:orientation="horizontal"
        android:paddingBottom="1.0dip"
        android:paddingLeft="4.0dip"
        android:paddingRight="4.0dip"
        android:paddingTop="5.0dip" >

        <Button
            android:id="@+id/btnEnglish"
            android:layout_width="0.0dip"
            android:layout_height="fill_parent"
            android:layout_weight="1.0"
            android:text="English" />

        <Button
            android:id="@+id/btnSpanish"
            android:layout_width="0.0dip"
            android:layout_height="fill_parent"
            android:layout_weight="1.0"
            android:text="Spanish" />
    </LinearLayout>
</LinearLayout>
Android Fragment Layout Issue (centre buttons vertically and horizontally)

Android Fragment Layout Issue (centre buttons vertically and horizontally)


By : 胡 博
Date : March 29 2020, 07:55 AM
wish help you to fix your issue you have to set width TableRow to android:layout_width="wrap_content" then make gravity center android:layout_gravity="center"
code :
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout  xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center_vertical"
    android:orientation="vertical" >

          <TableRow
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_gravity="center"
              android:paddingBottom="3dip"
              android:paddingLeft="10dip"
              android:paddingRight="10dip"
              android:paddingTop="10dip" >

          <Button
            android:id="@+id/Btn_Show"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Button 1" />

          <Button
              android:id="@+id/button2"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_gravity="center_horizontal"
              android:text="Button 2" />

         </TableRow>
          <TableRow
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_gravity="center"
              android:paddingBottom="3dip"
              android:paddingLeft="10dip"
              android:paddingRight="10dip"
              android:paddingTop="10dip" >
          <Button
            android:id="@+id/button3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Button 3" />
          <Button
            android:id="@+id/button4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Button 4" />
        </TableRow>

</LinearLayout>
</FrameLayout>
Centre icon and text vertically and horizontally

Centre icon and text vertically and horizontally


By : user3051219
Date : March 29 2020, 07:55 AM
this one helps. It's perfectly possible. Remove the float, and use a combination of display: inline-block and vertical-align: middle instead.
Here's the fiddle.
code :
.icon26:before {
    background: url(/assets/images/sprite26.png) no-repeat 0 0;
    content: "";
    display: inline-block; /* <-- instead of float: left */
    vertical-align: middle; /* <-- add to vertically center inline blocks */
    height: 2.6rem;
    width: 2.6rem;
}

#nav ul li {
    float: left;
    width: 33.33%;
    text-align: center; /* <-- add this to horizontally center inline items */
}
How Can I Centre Multiline Text Horizontally and Vertically Using PIL

How Can I Centre Multiline Text Horizontally and Vertically Using PIL


By : Ondřej Jánský
Date : March 29 2020, 07:55 AM
it should still fix some issue Both the frame and the text are centred around the top left hand corner and each offset is in pixels.
the value W is the width of the frame and H is the height of the frame.
Related Posts Related Posts :
  • React antd Upload input required error with default list
  • How to display dynamically fetched image on client end in react?
  • React: TypeError: Cannot read property 'prototype' of undefined
  • how can my call the action in my component using typescript with react redux?
  • typescript mapDispatchToProps got error when import component require pass actions as props
  • Change state of buttons
  • React doesn't render my Component, only if I restart my project
  • Function(method) is executing twice although only being called once
  • How can I remove a item class from a child's item in css and react?
  • React Devtools 4 DOM updates highlights
  • I am having trouble adding data to my table on submit
  • Axios post request is returning 401 unauthorised error
  • why is a React class component converted to functional component with hooks not picking up state in event handler on doc
  • How do I write a React Spring to change margin?
  • React tab doesn't appear in chrome developer tools
  • How to redirect to another component by setting up props from this component in react.js
  • Customize Reactive Search DateRange
  • Anyone know why my Component Keeps Remounting?
  • How to get the latest state value after using setState?
  • How to return value in component react typescript
  • RadioButton click TypeError: Cannot read property 'setState' of undefined
  • How should useDispatch be used to enforce type checking?
  • Property 'title' does not exist on type 'IntrinsicAttributes & IProps'
  • What are the disadvantages of client-only routes?
  • Dropping files or opening files from the file selector dialog box causes the React component to unmount
  • How to check if a component has been clicked after an onblur event in React
  • What should be considered as component in React
  • Updating Parents state from Child without triggering a rerender of Child in React
  • Select component is ignoring parent onClick event
  • How to add Condition inside render method in reactjs
  • How to fix form that will not allow text to be entered?
  • Cannot read property 'name' of undefined on React with my props
  • Material UI tooltip doesn't display on custom component, despite spreading props to that component
  • Unexpected output but expected view when using hooks React for toggle
  • Determine if two objects have an identical structure with Jest
  • Material ui - snackbox aria label not being read
  • Why is useState hook calling initialising value code twice?
  • React - override state by exists object properties
  • how to stop re-rendering of list items in context consumer when state changes
  • how to pass props one page to another page via react router?
  • How to display react numerical props only if they pass from the container?
  • Input in another component, error with target
  • What is the difference between props and children in Gatsby?
  • Validating conditional pairs of props with Typescript
  • React-Dropzone how convert each file to base64
  • How to change the return of a function to int?
  • Import only grid system from bootstrap to react
  • TypeScript Type for function arguments not erroring?
  • Unexpected user of comma operator no-sequences
  • React Native onChangeText like onChange in ReactJS
  • How to dynamically render an element on clicking a button
  • Cannot import components from react-bootstrap
  • How to prevent Office UI Fabric React DatePicker flyout from stealing focus when allowTextInput is true?
  • How delete item from redux state?
  • Uncaught TypeError: map is not a function In Reactjs with Firebase
  • Alternative to componentWillReceiveProps for my particular use case
  • Pokemon, API call Variable doesn't save
  • Rendered more hooks than during the previous render. when posting form data with React Hooks
  • How can I envoke <Link to=''> route transition from a custom function?
  • How to change certain div color base on number
  • shadow
    Privacy Policy - Terms - Contact Us © festivalmusicasacra.org