logo
Tags down

shadow

Place marker based on coordinate for different screen size (Flutter)


By : stephen mcgee
Date : September 16 2020, 06:00 PM
Hope this helps You can get the width and height of the screen with:
double new_width = MediaQuery.of(context).size.width; double new_height = MediaQuery.of(context).size.height;
code :


Share : facebook icon twitter icon

How can I place objects in my view based on the actual screen size in Android?


By : Kemparaju DM
Date : March 29 2020, 07:55 AM
may help you . My solution to this is to have a number of style types, which I place in the values-large, values-small, values-normal, and values-xlarge folders. A typical entry will look like this:
code :
<resources>
<style name="bigText">
    <item name="android:textSize">60dp</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="android:layout_width">wrap_content</item>
    <item name="android:layout_marginTop">5dp</item>
    <item name="android:layout_marginBottom">5dp</item>
    <item name="android:textColor">#000000</item>
</style>
</resources>
<TextView
    android:id="@+id/somTextValue"
    style="@style/bigText"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/someText" />

android move image from one place to another place on different screen size and resolutions


By : Anton Kryvoruchko
Date : March 29 2020, 07:55 AM
Does that help So, I tried to come up with a solution that uses simple unitary method to solve your problem. I am not sure if it works, I did not try it by coding it actually!
I am assuming that you have set the background static image to scale its size (width) to 100% of the screen, your static image is a square(usually a ludo board is). Also I am considering here that screenwidth is smaller than screenheight. If it is the other way around then exchange the formulae symbols.
code :
screenH = screen height in pixels;
screenW = screen width in pixels;

bgW = width of staticbackgroundimage in pixels;
bgH = height of staticbackgroundimage in pixels;
x= p*screenW/bgW;
screenHimage=bgH*screenW/bgW;

y=q*screenHimage/bgH;

Set marker size based on coordinate values, not pixels, in plotly R


By : Jenifer Ramirez
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further This post - Set marker size in plotly - unfortunately did not help with what I was looking for, and is the only post on the topic I could find. Per the plotly documentation on the size parameter for scatter plots: ,
Let's start with a plot with a defined axis range.
code :
p <- plot_ly() %>% layout(xaxis = list(range = c(1, 5)))
javascript <- "
var myPlot = document.getElementsByClassName('plotly')[0];

function resize(eventdata) {
  // magic happens here
}

myPlot.on('plotly_relayout', function(eventdata) {
  resize(eventdata);
});
"
p <- htmlwidgets::prependContent(p, 
                                 onStaticRenderComplete(javascript))
p
eventdata['xaxis.range[1]']
var plot_width = Plotly.d3.select('.xlines-above').node().getBBox()['width'];
library("plotly")
library("htmlwidgets")

p <- plot_ly() %>%
  add_trace(x = c(1.5, 3, 4.2),
            y = c(-2, 1, 2), 
            type = 'scatter',
            mode = 'lines+markers',
            showlegend = F) %>% 
  add_trace(x = c(2, 3, 4.2),
            y = c(2, 0, -1),
            type = 'scatter',
            mode = 'lines+markers',
            showlegend = F) %>%
  add_trace(x = c(1.5, 3, 4.2),
            y = c(1, 0.5, 1),
            type = 'scatter',
            mode = 'markers',
            showlegend = F) %>% 
  layout(xaxis = list(range = c(1, 5)))
javascript <- "
marker_size = 0.5; // x-axis units
var myPlot = document.getElementsByClassName('plotly')[0];

function resize(eventdata) {
  var xaxis_stop = 5;
  var xaxis_start = 1;
  var plot_width = Plotly.d3.select('.xlines-above').node().getBBox()['width'];
  if (eventdata['xaxis.range[1]'] !== undefined) {
    var update = {'marker.size': marker_size * plot_width / (eventdata['xaxis.range[1]'] - eventdata['xaxis.range[0]'])};
  } else {
    var update = {'marker.size': marker_size * plot_width / (xaxis_stop - xaxis_start)};
  }
  Plotly.restyle(myPlot, update, 2);
}
resize({eventdata: {}});

myPlot.on('plotly_relayout', function(eventdata) {
  resize(eventdata);
});
"
p <- htmlwidgets::prependContent(p, 
                                 onStaticRenderComplete(javascript))
p
var plot_width = 500;
var plot_height = 500;
var margin_l = 100;
var margin_r = 100;
marker_size = 0.5; // x-axis units
xaxis_start = 1;
xaxis_stop = 5;

var trace1 = {
  x: [1.5, 2, 3, 4],
  y: [10, 15, 13, 17],
  mode: "markers",
  marker: {
    size: marker_size *
      (plot_width - margin_l - margin_r) /
      (xaxis_stop - xaxis_start)
  },
  showlegend: false
};

var trace2 = {
  x: [2, 3, 4, 4.5],
  y: [16, 5, 11, 10],
  mode: "lines"
};

var trace3 = {
  x: [1.5, 2, 3, 4],
  y: [12, 9, 15, 12],
  mode: "lines+markers",
  showlegend: false
};

var data = [trace1, trace2, trace3];

var layout = {
  width: plot_width,
  height: plot_height,
  margin: {
    l: margin_l,
    r: margin_r
  },
  xaxis: {
    range: [1, 5]
  },
  showlegend: false
};

Plotly.newPlot("myDiv", data, layout);

var refplot = document.getElementById("myDiv");
refplot.on("plotly_relayout", function(eventdata) {
  if (eventdata["xaxis.range[1]"] !== undefined) {
    var update = {
      "marker.size": marker_size *
        (plot_width - margin_l - margin_r) /
        (eventdata["xaxis.range[1]"] - eventdata["xaxis.range[0]"])
    };
  } else {
    var update = {
      "marker.size": marker_size *
        (plot_width - margin_l - margin_r) /
        (xaxis_stop - xaxis_start)
    };
  }
  Plotly.restyle("myDiv", update, 0);
});
<head>
  <script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
</head>

<body>
  <div id="myDiv"></div>
</body>

Is it possible to calculate region based on specified coordinate and screen size


By : user1494383
Date : March 29 2020, 07:55 AM
seems to work fine I have a solution for this problem but it's done with MapKit (Apple Maps), so not sure if that really helps you but it might give you some idea maybe...
MapKit has this MKCoordinateRegion type:
code :
var region: MKCoordinateRegion {
    let regionSize = 10000.0
    let region = MKCoordinateRegionMakeWithDistance(coordinate, regionSize, regionSize)
    return region
}
map.setRegion(region, animated: animated)
let offset = CGPoint(x: 0, y: bottomViewHeight / 2)
let screenHeight = UIDevice.current.orientation == .portrait ? view.bounds.height : view.bounds.width
let offsetScreenPercentage = Double(offset.y / screenHeight)
region.center.latitude -= region.span.latitudeDelta * offsetScreenPercentage * 2

Flutter: How can I resize text based on device's screen size


By : logan_ch
Date : March 29 2020, 07:55 AM
may help you . For font size based on screen, I would suggest using Height as reference.
for example:
code :
 double unitHeightValue = MediaQuery.of(context).size.height * 0.01;
 double multiplier = 25;
 return Text(
  'Some Text', 
  style: TextStyle(
    fontSize: multiplier * unitHeightValue,
  ),
 );

Related Posts Related Posts :
  • How to get Screen size in Flutter when my app running in Split screen mode
  • Possible to swipe down image to return previous screen?
  • Flutter/Dart: How to make data load on the first tab when launching application?
  • How to create dynamic variables and assign list of data to it using flutter
  • why is Map and List instantiable and yet they are abstract classes in dart
  • Flutter SharedPreferences getInstance return null
  • Flutter: can I use setState() with a BLoC architecture?
  • How to have a Timer whose time keeps changing in dart?
  • ServicesBinding.defaultBinaryMessenger was accessed before the binding was initialized. E/flutter (21284):
  • Flutter Web : Is it Firebase Analytics support in Flutter web application?
  • How best to null check in for-in loop?
  • Type mismatch: inferred type is PluginRegistry? but FlutterEngine was expected
  • Fresh Flutter project has error: The function 'runApp' isn't defined
  • Bottom TextField with SnackBar
  • What is the meaning of `Class._()..property`?
  • How can I see when a Widget rebuilds?
  • Why the app produced by flutter build web sometimes doesn't work?
  • width not set after Transform.scale
  • How to play audio on the all platforms (including web) in Flutter
  • How to run a code-generator on the top of another code-generator?
  • How to restrict two dots in flutter?
  • The non-abstract class '_LoadingScreenState' is missing implementations
  • Unable to complete Flutter installation
  • Saving data between widgets in Flutter
  • Flutter release apk
  • set value in textfield from a list using stream/blocs
  • White/blank screen after close camera in Flutter
  • please explain how padding works?if i increase the padding ,it become smaller and if i decrease the padding,it become la
  • How to save and download text file in Flutter web application
  • Break on ForEach() dart
  • How to quickly duplicate and increase number?
  • How to dispose a sibling of parent widget on navigation
  • How to design Flutter textfield Like this
  • (flutter) the return type MaterialApp{...} shows error : Type cant be returned from method 'build' as it has return type
  • Text through border in flutter
  • Flutter can't connect to iOS simulator
  • How does `build` occur from root to leaves in Flutter?
  • Flutter directed graph. Can I use CustomPainter Class with custom widgets?
  • pushReplacementNamed not working in Flutter
  • How in dart, expose globaly an enum?
  • How to exclude files, classes, libraries or packages from dart obfuscation in flutter?
  • What caused this error ? (too many arguments) Flutter
  • Searchable spinner in Flutter
  • I want to build an app that just load my existing website with flutter
  • How to extend a flutter widget and set defaults on its inner values?
  • Flutter Provider's methods cant be called from classes
  • How can I have a ListView with 200 different images?
  • How to store theme in shared preferences in flutter
  • shadow
    Privacy Policy - Terms - Contact Us © 35dp-dentalpractice.co.uk